<!--
-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">
<head>
<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" />
</head>
<body>
<h1>Appendix C - Using MapBuilder Classes</h1>
<p>When Propel generates the object model for you project, it also generates MapBuilder
classes which are "static" 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
database.</p>
<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>
<pre>require_once("propel/Propel.php");
Propel::init("bookstore-conf.php");
require_once("Book.php");
require_once("Author.php");
require_once("Publisher.php");
require_once("propel/map/DatabaseMap.php");
try {
$dbMap = Propel::getDatabaseMap("bookstore");
$tables = $dbMap->getTables();
foreach ($tables as $tableName => $table) {
print "Table: $tableName\n";
$columns = $table->getColumns();
foreach ($columns as $column) {
$creoleType = CreoleTypes::getCreoleName($column->getCreoleType());
print "\tColumn: " . $column->getColumnName() . "\n";
print "\t\tFQN: " . $column->getFullyQualifiedName() . "\n";
if ($column->isPrimaryKey()) {
print "\t\tPrimary Key: true\n";
}
print "\t\tSize: " . $column->getSize() . "\n";
print "\t\tType: " . $column->getType() . "\n";
print "\t\tCreole Type: " . $creoleType . "\n";
}
}
} catch (Exception $e) {
die("Exception: " . $e);
}</pre>
</body>
</html>