[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 // Create a MapBuilder class for describing the current database at runtime. 4 // 5 // $Id: MapBuilder.tpl,v 1.3 2004/12/04 14:32:45 micha Exp $ 6 7 echo '<' . '?' . 'php'; 8 9 ?> 10 11 require_once 'propel/map/MapBuilder.php'; 12 include_once 'creole/CreoleTypes.php'; 13 14 /** 15 * This class adds structure of '<?php echo $table->getName() ?>' table to '<?php echo $table->getDatabase()->getName() ?>' DatabaseMap object. 16 * 17 * These statically-built map classes are used by Propel to do runtime db structure discovery. 18 * For example, the createSelectSql() method checks the type of a given column used in an 19 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 20 * (i.e. if it's a text column type). 21 * 22 <?php if ($addTimeStamp) { ?> 23 * This class was autogenerated by Propel on: 24 * 25 * [<?php echo $now ?>] 26 * 27 <?php } ?> 28 * @see BasePeer 29 * @see DatabaseMap 30 * @package <?php echo $package ?>.map; 31 */ 32 class <?php echo $table->getPhpName() ?>MapBuilder extends MapBuilder 33 { 34 /** 35 * Returns the name of this class. 36 */ 37 function CLASS_NAME() { return ("<?php echo $pkmap . '.' . $table->getPhpName() ?>MapBuilder"); } 38 39 /** 40 * The database map. 41 */ 42 var $dbMap = null; 43 44 /** 45 * Tells us if this DatabaseMapBuilder is built so that we 46 * don't have to re-build it every time. 47 * 48 * @return boolean TRUE if this DatabaseMapBuilder is built 49 */ 50 function isBuilt() 51 { 52 return ($this->dbMap !== null); 53 } 54 55 /** 56 * Gets the databasemap this map builder built. 57 * 58 * @return DatabaseMap This database map. 59 */ 60 function & getDatabaseMap() 61 { 62 return $this->dbMap; 63 } 64 65 /** 66 * The doBuild() method builds the DatabaseMap 67 * 68 * @return void 69 * @throws PropelException 70 */ 71 function doBuild() 72 { 73 $this->dbMap =& Propel::getDatabaseMap("<?php echo $table->getDatabase()->getName() ?>"); 74 75 $tMap =& $this->dbMap->addTable("<?php echo $table->getName()?>"); 76 $tMap->setPhpName("<?php echo $table->getPhpName()?>"); 77 78 <?php if ($table->getIdMethod() == "native") { ?> 79 $tMap->setUseIdGenerator(true); 80 <?php } else { ?> 81 $tMap->setUseIdGenerator(false); 82 <?php } ?> 83 84 <?php if ($table->getIdMethodParameters()) { 85 $params = $table->getIdMethodParameters(); 86 $imp = $params[0]; ?> 87 $tMap->setPrimaryKeyMethodInfo("<?php echo $imp->getValue() ?>"); 88 <?php } elseif ($table->getIdMethod() == "native" && ($platform->getNativeIdMethod() == Platform::SEQUENCE)) { ?> 89 $tMap->setPrimaryKeyMethodInfo("<?php echo $table->getSequenceName() ?>"); 90 <?php } elseif ($table->getIdMethod() == "native" && ($platform->getNativeIdMethod() == Platform::SEQUENCE)) { ?> 91 $tMap->setPrimaryKeyMethodInfo("<?php echo $table->getName() ?>"); 92 <?php } ?> 93 // Add columns to map 94 <?php foreach ($table->getColumns() as $col) { 95 $tfc=$table->getPhpName(); 96 $cfc=$col->getPhpName(); 97 $cup=strtoupper($col->getName()); 98 if($col->isPrimaryKey()) { 99 if($col->isForeignKey()) { ?> 100 $tMap->addForeignPrimaryKey("<?php echo $cup ?>", "<?php echo $cfc?>", "<?php echo $col->getPhpType() ?>" , CreoleTypes::<?php echo $col->getType() ?>(), "<?php echo $col->getRelatedTableName()?>" , "<?php echo strtoupper($col->getRelatedColumnName()) ?>", <?php echo $col->isNotNull() ? 'true' : 'false' ?>); 101 <?php } else { ?> 102 $tMap->addPrimaryKey("<?php echo $cup ?>", "<?php echo $cfc?>", "<?php echo $col->getPhpType() ?>", CreoleTypes::<?php echo $col->getType() ?>(), <?php echo $col->isNotNull() ? 'true' : 'false' ?>); 103 <?php } 104 105 } else { 106 if($col->isForeignKey()) { ?> 107 $tMap->addForeignKey("<?php echo $cup ?>", "<?php echo $cfc?>", "<?php echo $col->getPhpType()?>", CreoleTypes::<?php echo $col->getType() ?>(), "<?php echo $col->getRelatedTableName() ?>" , "<?php echo strtoupper($col->getRelatedColumnName()) ?>", <?php echo $col->isNotNull() ? 'true' : 'false' ?>); 108 <?php } else { 109 if (!$col->getSize()) { 110 $size = "null"; 111 } else { 112 $size = $col->getSize(); 113 } 114 ?> 115 $tMap->addColumn("<?php echo $cup ?>", "<?php echo $cfc?>", "<?php echo $col->getPhpType()?>", CreoleTypes::<?php echo $col->getType() ?>(), <?php echo $col->isNotNull() ? 'true' : 'false' ?>, <?php echo $size ?>); 116 <?php } 117 } // if col-is prim key 118 } // foreach 119 120 foreach($table->getValidators() as $val) { 121 $col = $val->getColumn(); 122 $cup = strtoupper($col->getName()); 123 foreach($val->getRules() as $rule) { 124 if ($val->getTranslate() !== Validator::TRANSLATE_NONE) { 125 ?> 126 $tMap->addValidator("<?php echo $cup ?>", "<?php echo $rule->getName() ?>", "<?php echo $rule->getClass() ?>", "<?php echo $rule->getValue()?>", <?php echo $val->getTranslate() ?>("<?php echo str_replace('"', '\"', $rule->getMessage()) ?>")); 127 <?php } else { ?> 128 $tMap->addValidator("<?php echo $cup ?>", "<?php echo $rule->getName() ?>", "<?php echo $rule->getClass() ?>", "<?php echo $rule->getValue()?>", "<?php echo str_replace('"', '\"', $rule->getMessage()) ?>"); 129 <?php 130 } // if ($rule->getTranslation() ... 131 } // foreach validator 132 } 133 ?> 134 } 135 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |