lazyrecord\schema\DeclareSchema::table PHP Method

table() public method

Define table name.
public table ( string $table )
$table string table name
    public function table($table)
    {
        $this->table = $table;
        return $this;
    }

Usage Example

 public function reverseTableSchema($table)
 {
     $tableDef = $this->parseTableSql($table);
     $schema = new DeclareSchema();
     $schema->columnNames = $schema->columns = array();
     $schema->table($table);
     foreach ($tableDef->columns as $columnDef) {
         $name = $columnDef->name;
         $column = $schema->column($name);
         if (!isset($columnDef->type)) {
             throw new LogicException("Missing column type definition on column {$table}.{$name}.");
         }
         $type = $columnDef->type;
         $typeInfo = TypeInfoParser::parseTypeInfo($type, $this->driver);
         $column->type($type);
         if (isset($columnDef->length)) {
             $column->length($columnDef->length);
         }
         if (isset($columnDef->decimals)) {
             $column->decimals($columnDef->decimals);
         }
         $isa = $this->typenameToIsa($type);
         $column->isa($isa);
         if (isset($columnDef->notNull) && $columnDef->notNull !== null) {
             if ($columnDef->notNull) {
                 $column->notNull();
             } else {
                 $column->null();
             }
         }
         if (isset($columnDef->primary)) {
             $column->primary(true);
             $schema->primaryKey = $name;
             if (isset($columnDef->autoIncrement)) {
                 $column->autoIncrement(true);
             }
         } else {
             if (isset($columnDef->unique)) {
                 $column->unique(true);
             }
         }
         if (isset($columnDef->default)) {
             $default = $columnDef->default;
             if (is_scalar($default)) {
                 $column->default($default);
             } else {
                 if ($default instanceof Token && $default->type == 'literal') {
                     $column->default(new Raw($default->val));
                 } else {
                     throw new Exception('Incorrect literal token');
                 }
             }
         }
     }
     return $schema;
 }
All Usage Examples Of lazyrecord\schema\DeclareSchema::table