Exemplo n.º 1
0
 /**
  * Add a column to the table.
  *
  * @param  string                        $name         A String with the column name.
  * @param  string                        $phpName      A string representing the PHP name.
  * @param  string                        $type         A string specifying the Propel type.
  * @param  boolean                       $isNotNull    Whether column does not allow NULL values.
  * @param  int                           $size         An int specifying the size.
  * @param  boolean                       $pk           True if column is a primary key.
  * @param  string                        $fkTable      A String with the foreign key table name.
  * @param  string                        $fkColumn     A String with the foreign key column name.
  * @param  string                        $defaultValue The default value for this column.
  * @return \Propel\Runtime\Map\ColumnMap The newly created column.
  */
 public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null)
 {
     $col = new ColumnMap($name, $this);
     $col->setType($type);
     $col->setSize($size);
     $col->setPhpName($phpName);
     $col->setNotNull($isNotNull);
     $col->setDefaultValue($defaultValue);
     if ($pk) {
         $col->setPrimaryKey(true);
         $this->primaryKeys[$name] = $col;
     }
     if ($fkTable && $fkColumn) {
         $col->setForeignKey($fkTable, $fkColumn);
         $this->foreignKeys[$name] = $col;
     }
     $this->columns[ColumnMap::normalizeName($name)] = $col;
     $this->columnsByPhpName[$phpName] = $col;
     return $col;
 }
Exemplo n.º 2
0
 public function testPrimaryStringAddConfiguredColumn()
 {
     $this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false while none set.');
     $column = new ColumnMap('BAR', $this->tmap);
     $column->setPhpName('Bar');
     $column->setType('VARCHAR');
     $column->setPrimaryString(true);
     $this->tmap->addConfiguredColumn($column);
     $this->assertTrue($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns true after adding pkStr column.');
     $this->assertEquals($column, $this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns correct column.');
 }
Exemplo n.º 3
0
 public function getPrimaryKeys()
 {
     $cm = new ColumnMap('id', new TableMap());
     $cm->setType('INTEGER');
     return array('id' => $cm);
 }