示例#1
0
文件: Table.php 项目: disider/Propel2
 /**
  * Adds a new column to the table.
  *
  * @param  Column|array    $col
  * @throws EngineException
  * @return Column
  */
 public function addColumn($col)
 {
     if ($col instanceof Column) {
         if (isset($this->columnsByName[$col->getName()])) {
             throw new EngineException(sprintf('Column "%s" declared twice in table "%s"', $col->getName(), $this->getName()));
         }
         $col->setTable($this);
         if ($col->isInheritance()) {
             $this->inheritanceColumn = $col;
         }
         $this->columns[] = $col;
         $this->columnsByName[$col->getName()] = $col;
         $this->columnsByLowercaseName[strtolower($col->getName())] = $col;
         $this->columnsByPhpName[$col->getPhpName()] = $col;
         $col->setPosition(count($this->columns));
         if ($col->requiresTransactionInPostgres()) {
             $this->needsTransactionInPostgres = true;
         }
         return $col;
     }
     $column = new Column();
     $column->setTable($this);
     $column->loadMapping($col);
     return $this->addColumn($column);
     // call self w/ different param
 }
 public function testSetPosition()
 {
     $column = new Column();
     $column->setPosition(2);
     $this->assertSame(2, $column->getPosition());
 }