[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/propel-generator/templates/om/php5/ -> MapBuilder.tpl (source)

   1  <?php
   2  
   3  // Create a MapBuilder class for describing the current database at runtime.
   4  //
   5  // $Id: MapBuilder.tpl,v 1.2 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 implements MapBuilder {
  33  
  34      /**
  35       * The name of this class
  36       */
  37      const CLASS_NAME = "<?php echo $pkmap . '.' . $table->getPhpName() ?>MapBuilder";
  38      
  39      /**
  40       * The database map.
  41       */
  42      private $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 true if this DatabaseMapBuilder is built
  49       */
  50      public function isBuilt()
  51      {
  52          return ($this->dbMap !== null);
  53      }
  54  
  55      /**
  56       * Gets the databasemap this map builder built.
  57       *
  58       * @return the databasemap
  59       */
  60      public 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      public 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          
  94          // Add columns to map
  95  <?php foreach ($table->getColumns() as $col) {
  96      $tfc=$table->getPhpName();
  97      $cfc=$col->getPhpName();
  98      $cup=strtoupper($col->getName());
  99      if (!$col->getSize()) {
 100          $size = "null";
 101      } else {
 102          $size = $col->getSize();
 103      }
 104      if($col->isPrimaryKey()) {
 105          if($col->isForeignKey()) { ?>
 106          $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' ?>, <?php echo $size ?>);
 107  <?php    } else { ?>
 108          $tMap->addPrimaryKey("<?php echo $cup ?>", "<?php echo $cfc?>", "<?php echo $col->getPhpType() ?>", CreoleTypes::<?php echo $col->getType() ?>, <?php echo $col->isNotNull() ? 'true' : 'false' ?>, <?php echo $size ?>);
 109  <?php } 
 110  
 111      } else {
 112          if($col->isForeignKey()) { ?>
 113          $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' ?>, <?php echo $size ?>);
 114  <?php    } else { ?>
 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  foreach($table->getValidators() as $val) {
 120    $col = $val->getColumn();
 121    $cup = strtoupper($col->getName());
 122    foreach($val->getRules() as $rule) {
 123      if ($val->getTranslate() !== Validator::TRANSLATE_NONE) {
 124  ?>
 125          $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()) ?>"));
 126  <?php } else { ?>
 127          $tMap->addValidator("<?php echo $cup ?>", "<?php echo $rule->getName() ?>", "<?php echo $rule->getClass() ?>", "<?php echo $rule->getValue()?>", "<?php echo str_replace('"', '\"', $rule->getMessage()) ?>");
 128  <?php        
 129      } // if ($rule->getTranslation() ...
 130    } // foreach validator
 131  }
 132  ?>
 133                  
 134      }
 135  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7