Ejemplo n.º 1
0
 /**
  * Add a column to the table.
  *
  * @param      string name A String with the column name.
  * @param      string $type A string specifying the PHP native type.
  * @param      int $creoleType The integer representing the Creole 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      $fkColumn A String with the foreign key column name.
  * @param      string $defaultValue The default value for this column.
  * @return     ColumnMap The newly created column.
  */
 public function addColumn($name, $phpName, $type, $creoleType, $isNotNull = false, $size = null, $pk = null, $fkTable = null, $fkColumn = null)
 {
     $col = new ColumnMap($name, $this);
     if ($fkTable && $fkColumn) {
         if (substr_count($fkColumn, '.') > 0 && substr($fkColumn, strlen($fkTable)) !== false) {
             $fkColumn = substr($fkColumn, strlen($fkTable) + 1);
         }
         $col->setForeignKey($fkTable, $fkColumn);
     }
     $col->setType($type);
     $col->setCreoleType($creoleType);
     $col->setPrimaryKey($pk);
     $col->setSize($size);
     $col->setPhpName($phpName);
     $col->setNotNull($isNotNull);
     $this->columns[$name] = $col;
     return $this->columns[$name];
 }