db\QueryBuilder createTable()

createTable() public method

Builds a SQL statement for creating a new DB table.

The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name stands for a column name which will be properly quoted by the method, and definition stands for the column type which can contain an abstract DB type. The getColumnType() method will be invoked to convert any abstract type into a physical one.

If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly inserted into the generated SQL.

For example,

$sql = $queryBuilder->createTable('user', [
 'id' => 'pk',
 'name' => 'string',
 'age' => 'integer',
]);
public string createTable ( $table, $columns, $options = null )
$table string

The name of the table to be created. The name will be properly quoted by the method.

$columns array

The columns (name => definition) in the new table.

$options string

Additional SQL fragment that will be appended to the generated SQL.

return string

The SQL statement for creating a new DB table.

doc_Yii
2016-10-30 16:59:18
Comments
Leave a Comment

Please login to continue.