Methods summary
public
|
#
resetSequence( CDbTableSchema $table, integer|null $value = null )
Resets the sequence value of a table's primary key. The sequence will be
reset such that the primary key of the next new row inserted will have the
specified value or max value of a primary key plus one (i.e. sequence
trimming).
Resets the sequence value of a table's primary key. The sequence will be
reset such that the primary key of the next new row inserted will have the
specified value or max value of a primary key plus one (i.e. sequence
trimming).
Parameters
- $table
CDbTableSchema
$table the table schema whose primary key sequence will be reset
- $value
integer|null $value the value for the primary key of the next new row inserted. If this is
not set, the next new row's primary key will have the max value of a primary key
plus one (i.e. sequence trimming).
Since
1.1
Overrides
|
public
|
#
checkIntegrity( boolean $check = true, string $schema = '' )
Enables or disables integrity check. Note that this method used to do nothing
before 1.1.14. Since 1.1.14 it changes integrity check state as expected.
Enables or disables integrity check. Note that this method used to do nothing
before 1.1.14. Since 1.1.14 it changes integrity check state as expected.
Parameters
- $check
boolean $check whether to turn on or off the integrity check.
- $schema
string $schema the schema of the tables. Defaults to empty string, meaning the current
or default schema.
Since
1.1
Overrides
|
protected
array
|
#
findTableNames( string $schema = '' )
Returns all table names in the database.
Returns all table names in the database.
Parameters
- $schema
string $schema the schema of the tables. This is not used for sqlite database.
Returns
array all table names in the database.
Throws
CDbException
if current schema does not support fetching all table names
Overrides
|
protected
CSqliteCommandBuilder
|
#
createCommandBuilder( )
Creates a command builder for the database.
Creates a command builder for the database.
Returns
Overrides
|
protected
CDbTableSchema
|
#
loadTable( string $name )
Loads the metadata for the specified table.
Loads the metadata for the specified table.
Parameters
- $name
string $name table name
Returns
CDbTableSchema
driver dependent table metadata. Null if the table does not exist.
|
protected
boolean
|
#
findColumns( CDbTableSchema $table )
Collects the table column metadata.
Collects the table column metadata.
Parameters
Returns
boolean whether the table exists in the database
|
protected
|
#
findConstraints( CDbTableSchema $table )
Collects the foreign key column details for the given table.
Collects the foreign key column details for the given table.
Parameters
|
protected
CDbColumnSchema
|
#
createColumn( array $column )
Creates a table column.
Parameters
- $column
array $column column metadata
Returns
|
public
string
|
#
renameTable( string $table, string $newName )
Builds a SQL statement for renaming a DB table.
Builds a SQL statement for renaming a DB table.
Parameters
- $table
string $table the table to be renamed. The name will be properly quoted by the method.
- $newName
string $newName the new table name. The name will be properly quoted by the method.
Returns
string the SQL statement for renaming a DB table.
Since
1.1.13
Overrides
|
public
string
|
#
truncateTable( string $table )
Builds a SQL statement for truncating a DB table.
Builds a SQL statement for truncating a DB table.
Parameters
- $table
string $table the table to be truncated. The name will be properly quoted by the
method.
Returns
string the SQL statement for truncating a DB table.
Since
1.1.6
Overrides
|
public
string
|
#
dropColumn( string $table, string $column )
Builds a SQL statement for dropping a DB column. Because SQLite does not
support dropping a DB column, calling this method will throw an exception.
Builds a SQL statement for dropping a DB column. Because SQLite does not
support dropping a DB column, calling this method will throw an exception.
Parameters
- $table
string $table the table whose column is to be dropped. The name will be properly quoted
by the method.
- $column
string $column the name of the column to be dropped. The name will be properly quoted
by the method.
Returns
string the SQL statement for dropping a DB column.
Since
1.1.6
Overrides
|
public
string
|
#
renameColumn( string $table, string $name, string $newName )
Builds a SQL statement for renaming a column. Because SQLite does not support
renaming a DB column, calling this method will throw an exception.
Builds a SQL statement for renaming a column. Because SQLite does not support
renaming a DB column, calling this method will throw an exception.
Parameters
- $table
string $table the table whose column is to be renamed. The name will be properly quoted
by the method.
- $name
string $name the old name of the column. The name will be properly quoted by the
method.
- $newName
string $newName the new name of the column. The name will be properly quoted by the
method.
Returns
string the SQL statement for renaming a DB column.
Since
1.1.6
Overrides
|
public
string
|
#
addForeignKey( string $name, string $table, string $columns, string $refTable, string $refColumns, string $delete = null, string $update = null )
Builds a SQL statement for adding a foreign key constraint to an existing
table. Because SQLite does not support adding foreign key to an existing table,
calling this method will throw an exception.
Builds a SQL statement for adding a foreign key constraint to an existing
table. Because SQLite does not support adding foreign key to an existing table,
calling this method will throw an exception.
Parameters
- $name
string $name the name of the foreign key constraint.
- $table
string $table the table that the foreign key constraint will be added to.
- $columns
string $columns the name of the column to that the constraint will be added on. If
there are multiple columns, separate them with commas.
- $refTable
string $refTable the table that the foreign key references to.
- $refColumns
string $refColumns the name of the column that the foreign key references to. If there
are multiple columns, separate them with commas.
- $delete
string $delete the ON DELETE option. Most DBMS support these options: RESTRICT,
CASCADE, NO ACTION, SET DEFAULT, SET NULL
- $update
string $update the ON UPDATE option. Most DBMS support these options: RESTRICT,
CASCADE, NO ACTION, SET DEFAULT, SET NULL
Returns
string the SQL statement for adding a foreign key constraint to an existing table.
Since
1.1.6
Overrides
|
public
string
|
#
dropForeignKey( string $name, string $table )
Builds a SQL statement for dropping a foreign key constraint. Because SQLite
does not support dropping a foreign key constraint, calling this method will
throw an exception.
Builds a SQL statement for dropping a foreign key constraint. Because SQLite
does not support dropping a foreign key constraint, calling this method will
throw an exception.
Parameters
- $name
string $name the name of the foreign key constraint to be dropped. The name will be
properly quoted by the method.
- $table
string $table the table whose foreign is to be dropped. The name will be properly
quoted by the method.
Returns
string the SQL statement for dropping a foreign key constraint.
Since
1.1.6
Overrides
|
public
string
|
#
alterColumn( string $table, string $column, string $type )
Builds a SQL statement for changing the definition of a column. Because
SQLite does not support altering a DB column, calling this method will throw an
exception.
Builds a SQL statement for changing the definition of a column. Because
SQLite does not support altering a DB column, calling this method will throw an
exception.
Parameters
- $table
string $table the table whose column is to be changed. The table name will be properly
quoted by the method.
- $column
string $column the name of the column to be changed. The name will be properly quoted
by the method.
- $type
string $type the new column type. The CDbSchema::getColumnType() method will be invoked to
convert abstract column type (if any) into the physical one. Anything that is
not recognized as abstract type will be kept in the generated SQL. For example,
'string' will be turned into 'varchar(255)', while 'string not null' will become
'varchar(255) not null'.
Returns
string the SQL statement for changing the definition of a column.
Since
1.1.6
Overrides
|
public
string
|
#
dropIndex( string $name, string $table )
Builds a SQL statement for dropping an index.
Builds a SQL statement for dropping an index.
Parameters
- $name
string $name the name of the index to be dropped. The name will be properly quoted by
the method.
- $table
string $table the table whose index is to be dropped. The name will be properly quoted
by the method.
Returns
string the SQL statement for dropping an index.
Since
1.1.6
Overrides
|
public
string
|
#
addPrimaryKey( string $name, string $table, string|array $columns )
Builds a SQL statement for adding a primary key constraint to an existing
table. Because SQLite does not support adding a primary key on an existing table
this method will throw an exception.
Builds a SQL statement for adding a primary key constraint to an existing
table. Because SQLite does not support adding a primary key on an existing table
this method will throw an exception.
Parameters
- $name
string $name the name of the primary key constraint.
- $table
string $table the table that the primary key constraint will be added to.
- $columns
string|array $columns comma separated string or array of columns that the primary key will
consist of.
Returns
string the SQL statement for adding a primary key constraint to an existing table.
Since
1.1.13
Overrides
|
public
string
|
#
dropPrimaryKey( string $name, string $table )
Builds a SQL statement for removing a primary key constraint to an existing
table. Because SQLite does not support dropping a primary key from an existing
table this method will throw an exception
Builds a SQL statement for removing a primary key constraint to an existing
table. Because SQLite does not support dropping a primary key from an existing
table this method will throw an exception
Parameters
- $name
string $name the name of the primary key constraint to be removed.
- $table
string $table the table that the primary key constraint will be removed from.
Returns
string the SQL statement for removing a primary key constraint from an existing table.
Since
1.1.13
Overrides
|