Location: PHPKode > projects > DIY Blog > diy-blog/lib/propel/docs/en/user_guide/book/chapters/appendices/AppendixC-MapBuilders.html
-File         $Id: AppendixC-MapBuilders.html,v 1.1 2004/07/08 01:17:06 hlellelid Exp $
-License      GNU FDL (http://www.gnu.org/copyleft/fdl.html)
-Copyright    2003, Propel project
-Author       Hans Lellelid, hide@address.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <title>Propel Guide</title> 
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="Stylesheet" rev="Stylesheet" href="../../css/Documentation.css" type="text/css" media="All" charset="iso-8859-1" />
<h1>Appendix C - Using MapBuilder Classes</h1>
<p>When Propel generates the object model for you project, it also generates MapBuilder 
  classes which are &quot;static&quot; classes that represent your database structure. 
  These classes are used for determining, e.g., which columns ar primary keys, 
  foreign keys, etc. at runtime without requiring any metadata operations on your 
<p>While you don't need to know anything about these classes -- since they are 
  only used inside the generated base peer classes and core Propel classes -- 
  they do provide an quick and powerful way to get metadata for your database.</p>




try {

  $dbMap = Propel::getDatabaseMap("bookstore");

  $tables = $dbMap-&gt;getTables();

  foreach ($tables as $tableName =&gt; $table) {
    print "Table: $tableName\n";
    $columns = $table-&gt;getColumns();
    foreach ($columns as $column) {
      $creoleType = CreoleTypes::getCreoleName($column-&gt;getCreoleType());
      print "\tColumn: " . $column-&gt;getColumnName() . "\n";
      print "\t\tFQN: " . $column-&gt;getFullyQualifiedName() .  "\n";
      if ($column-&gt;isPrimaryKey()) {
        print "\t\tPrimary Key: true\n";
      print "\t\tSize: " . $column-&gt;getSize() . "\n";
      print "\t\tType: " . $column-&gt;getType() . "\n";
      print "\t\tCreole Type: " . $creoleType . "\n";

} catch (Exception $e) {
  die("Exception: " . $e);
Return current item: DIY Blog