CDbSchema

优质
小牛编辑
126浏览
2023-12-01
所有包 | 属性 | 方法
system.db.schema
继承abstract class CDbSchema » CComponent
子类CMssqlSchema, CMysqlSchema, COciSchema, CPgsqlSchema, CSqliteSchema
源自1.0
版本$Id: CDbSchema.php 3515 2011-12-28 12:29:24Z mdomba $
源码framework/db/schema/CDbSchema.php
CDbSchema is the base class for retrieving metadata information.

公共属性

隐藏继承属性

属性类型描述定义在
columnTypesarraythe abstract column types mapped to physical column types.CDbSchema
commandBuilderCDbCommandBuilderthe SQL command builder for this connection.CDbSchema
dbConnectionCDbConnectiondatabase connection.CDbSchema
tableNamesarrayReturns all table names in the database.CDbSchema
tablesarrayReturns the metadata for all tables in the database.CDbSchema

公共方法

隐藏继承方法

方法描述定义在
__call()如果类中没有调的方法名,则调用这个方法。CComponent
__construct()Constructor.CDbSchema
__get()返回一个属性值、一个事件处理程序列表或一个行为名称。CComponent
__isset()检查一个属性是否为null。CComponent
__set()设置一个组件的属性值。CComponent
__unset()设置一个组件的属性为null。CComponent
addColumn()Builds a SQL statement for adding a new DB column.CDbSchema
addForeignKey()Builds a SQL statement for adding a foreign key constraint to an existing table.CDbSchema
alterColumn()Builds a SQL statement for changing the definition of a column.CDbSchema
asa()返回这个名字的行为对象。CComponent
attachBehavior()附加一个行为到组件。CComponent
attachBehaviors()附加一个行为列表到组件。CComponent
attachEventHandler()为事件附加一个事件处理程序。CComponent
canGetProperty()确定属性是否可读。CComponent
canSetProperty()确定属性是否可写。CComponent
checkIntegrity()Enables or disables integrity check.CDbSchema
compareTableNames()Compares two table names.CDbSchema
createIndex()Builds a SQL statement for creating a new index.CDbSchema
createTable()Builds a SQL statement for creating a new DB table.CDbSchema
detachBehavior()从组件中分离一个行为。CComponent
detachBehaviors()从组件中分离所有行为。CComponent
detachEventHandler()分离一个存在的事件处理程序。CComponent
disableBehavior()禁用一个附加行为。CComponent
disableBehaviors()禁用组件附加的所有行为。CComponent
dropColumn()Builds a SQL statement for dropping a DB column.CDbSchema
dropForeignKey()Builds a SQL statement for dropping a foreign key constraint.CDbSchema
dropIndex()Builds a SQL statement for dropping an index.CDbSchema
dropTable()Builds a SQL statement for dropping a DB table.CDbSchema
enableBehavior()启用一个附加行为。CComponent
enableBehaviors()启用组件附加的所有行为。CComponent
evaluateExpression()计算一个PHP表达式,或根据组件上下文执行回调。CComponent
getColumnType()Converts an abstract column type into a physical column type.CDbSchema
getCommandBuilder()返回the SQL command builder for this connection.CDbSchema
getDbConnection()返回database connection. The connection is active.CDbSchema
getEventHandlers()返回一个事件的附加处理程序列表。CComponent
getTable()Obtains the metadata for the named table.CDbSchema
getTableNames()Returns all table names in the database.CDbSchema
getTables()Returns the metadata for all tables in the database.CDbSchema
hasEvent()确定一个事件是否定义。CComponent
hasEventHandler()检查事件是否有附加的处理程序。CComponent
hasProperty()确定属性是否被定义。CComponent
quoteColumnName()Quotes a column name for use in a query.CDbSchema
quoteSimpleColumnName()Quotes a simple column name for use in a query.CDbSchema
quoteSimpleTableName()Quotes a simple table name for use in a query.CDbSchema
quoteTableName()Quotes a table name for use in a query.CDbSchema
raiseEvent()发起一个事件。CComponent
refresh()Refreshes the schema.CDbSchema
renameColumn()Builds a SQL statement for renaming a column.CDbSchema
renameTable()Builds a SQL statement for renaming a DB table.CDbSchema
resetSequence()Resets the sequence value of a table's primary key.CDbSchema
truncateTable()Builds a SQL statement for truncating a DB table.CDbSchema

受保护方法

隐藏继承方法

方法描述定义在
createCommandBuilder()Creates a command builder for the database.CDbSchema
findTableNames()Returns all table names in the database.CDbSchema
loadTable()Loads the metadata for the specified table.CDbSchema

属性详细

columnTypes 属性 (可用自 v1.1.6) public array $columnTypes;

the abstract column types mapped to physical column types.

commandBuilder 属性 只读 public CDbCommandBuilder getCommandBuilder()

the SQL command builder for this connection.

dbConnection 属性 只读 public CDbConnection getDbConnection()

database connection. The connection is active.

tableNames 属性 只读 public array getTableNames(string $schema='')

Returns all table names in the database.

tables 属性 只读 public array getTables(string $schema='')

Returns the metadata for all tables in the database.

方法详细

__construct() 方法
public void __construct(CDbConnection $conn)
$connCDbConnectiondatabase connection.
源码: framework/db/schema/CDbSchema.php#51 (显示) publicfunction__construct($conn)
{
$this->_connection=$conn;
foreach($conn->schemaCachingExcludeas$name)
$this->_cacheExclude[$name]=true;
}

Constructor.

addColumn() 方法 (可用自 v1.1.6)
public string addColumn(string $table, string $column, string $type)
$tablestringthe table that the new column will be added to. The table name will be properly quoted by the method.
$columnstringthe name of the new column. The name will be properly quoted by the method.
$typestringthe column type. The 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'.
{return}stringthe SQL statement for adding a new column.
源码: framework/db/schema/CDbSchema.php#427 (显示) publicfunctionaddColumn($table,$column,$type)
{
return'ALTERTABLE'.$this->quoteTableName($table)
.'ADD'.$this->quoteColumnName($column).''
.$this->getColumnType($type);
}

Builds a SQL statement for adding a new DB column.

addForeignKey() 方法 (可用自 v1.1.6)
public string addForeignKey(string $name, string $table, string $columns, string $refTable, string $refColumns, string $delete=NULL, string $update=NULL)
$namestringthe name of the foreign key constraint.
$tablestringthe table that the foreign key constraint will be added to.
$columnsstringthe name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas.
$refTablestringthe table that the foreign key references to.
$refColumnsstringthe name of the column that the foreign key references to. If there are multiple columns, separate them with commas.
$deletestringthe ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
$updatestringthe ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
{return}stringthe SQL statement for adding a foreign key constraint to an existing table.
源码: framework/db/schema/CDbSchema.php#493 (显示) publicfunctionaddForeignKey($name,$table,$columns,$refTable,$refColumns,$delete=null,$update=null)
{
$columns=preg_split('/s*,s*/',$columns,-1,PREG_SPLIT_NO_EMPTY);
foreach($columnsas$i=>$col)
$columns[$i]=$this->quoteColumnName($col);
$refColumns=preg_split('/s*,s*/',$refColumns,-1,PREG_SPLIT_NO_EMPTY);
foreach($refColumnsas$i=>$col)
$refColumns[$i]=$this->quoteColumnName($col);
$sql='ALTERTABLE'.$this->quoteTableName($table)
.'ADDCONSTRAINT'.$this->quoteColumnName($name)
.'FOREIGNKEY('.implode(',',$columns).')'
.'REFERENCES'.$this->quoteTableName($refTable)
.'('.implode(',',$refColumns).')';
if($delete!==null)
$sql.='ONDELETE'.$delete;
if($update!==null)
$sql.='ONUPDATE'.$update;
return$sql;
}

Builds a SQL statement for adding a foreign key constraint to an existing table. The method will properly quote the table and column names.

alterColumn() 方法 (可用自 v1.1.6)
public string alterColumn(string $table, string $column, string $type)
$tablestringthe table whose column is to be changed. The table name will be properly quoted by the method.
$columnstringthe name of the column to be changed. The name will be properly quoted by the method.
$typestringthe new column type. The 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'.
{return}stringthe SQL statement for changing the definition of a column.
源码: framework/db/schema/CDbSchema.php#472 (显示) publicfunctionalterColumn($table,$column,$type)
{
return'ALTERTABLE'.$this->quoteTableName($table).'CHANGE'
.$this->quoteColumnName($column).''
.$this->quoteColumnName($column).''
.$this->getColumnType($type);
}

Builds a SQL statement for changing the definition of a column.

checkIntegrity() 方法 (可用自 v1.1)
public void checkIntegrity(boolean $check=true, string $schema='')
$checkbooleanwhether to turn on or off the integrity check.
$schemastringthe schema of the tables. Defaults to empty string, meaning the current or default schema.
源码: framework/db/schema/CDbSchema.php#284 (显示) publicfunctioncheckIntegrity($check=true,$schema='')
{
}

Enables or disables integrity check.

compareTableNames() 方法
public boolean compareTableNames(string $name1, string $name2)
$name1stringtable name 1
$name2stringtable name 2
{return}booleanwhether the two table names refer to the same table.
源码: framework/db/schema/CDbSchema.php#247 (显示) publicfunctioncompareTableNames($name1,$name2)
{
$name1=str_replace(array('"','`',"'"),'',$name1);
$name2=str_replace(array('"','`',"'"),'',$name2);
if(($pos=strrpos($name1,'.'))!==false)
$name1=substr($name1,$pos+1);
if(($pos=strrpos($name2,'.'))!==false)
$name2=substr($name2,$pos+1);
if($this->_connection->tablePrefix!==null)
{
if(strpos($name1,'{')!==false)
$name1=$this->_connection->tablePrefix.str_replace(array('{','}'),'',$name1);
if(strpos($name2,'{')!==false)
$name2=$this->_connection->tablePrefix.str_replace(array('{','}'),'',$name2);
}
return$name1===$name2;
}

Compares two table names. The table names can be either quoted or unquoted. This method will consider both cases.

createCommandBuilder() 方法
protected CDbCommandBuilder createCommandBuilder()
{return}CDbCommandBuildercommand builder instance
源码: framework/db/schema/CDbSchema.php#293 (显示) protectedfunctioncreateCommandBuilder()
{
returnnewCDbCommandBuilder($this);
}

Creates a command builder for the database. This method may be overridden by child classes to create a DBMS-specific command builder.

createIndex() 方法 (可用自 v1.1.6)
public string createIndex(string $name, string $table, string $column, boolean $unique=false)
$namestringthe name of the index. The name will be properly quoted by the method.
$tablestringthe table that the new index will be created for. The table name will be properly quoted by the method.
$columnstringthe column(s) that should be included in the index. If there are multiple columns, please separate them by commas. Each column name will be properly quoted by the method, unless a parenthesis is found in the name.
$uniquebooleanwhether to add UNIQUE constraint on the created index.
{return}stringthe SQL statement for creating a new index.
源码: framework/db/schema/CDbSchema.php#536 (显示) publicfunctioncreateIndex($name,$table,$column,$unique=false)
{
$cols=array();
$columns=preg_split('/s*,s*/',$column,-1,PREG_SPLIT_NO_EMPTY);
foreach($columnsas$col)
{
if(strpos($col,'(')!==false)
$cols[]=$col;
else
$cols[]=$this->quoteColumnName($col);
}
return($unique?'CREATEUNIQUEINDEX':'CREATEINDEX')
.$this->quoteTableName($name).'ON'
.$this->quoteTableName($table).'('.implode(',',$cols).')';
}

Builds a SQL statement for creating a new index.

createTable() 方法 (可用自 v1.1.6)
public string createTable(string $table, array $columns, string $options=NULL)
$tablestringthe name of the table to be created. The name will be properly quoted by the method.
$columnsarraythe columns (name=>definition) in the new table.
$optionsstringadditional SQL fragment that will be appended to the generated SQL.
{return}stringthe SQL statement for creating a new DB table.
源码: framework/db/schema/CDbSchema.php#369 (显示) publicfunctioncreateTable($table,$columns,$options=null)
{
$cols=array();
foreach($columnsas$name=>$type)
{
if(is_string($name))
$cols[]="t".$this->quoteColumnName($name).''.$this->getColumnType($type);
else
$cols[]="t".$type;
}
$sql="CREATETABLE".$this->quoteTableName($table)."(n".implode(",n",$cols)."n)";
return$options===null?$sql:$sql.''.$options;
}

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.

dropColumn() 方法 (可用自 v1.1.6)
public string dropColumn(string $table, string $column)
$tablestringthe table whose column is to be dropped. The name will be properly quoted by the method.
$columnstringthe name of the column to be dropped. The name will be properly quoted by the method.
{return}stringthe SQL statement for dropping a DB column.
源码: framework/db/schema/CDbSchema.php#441 (显示) publicfunctiondropColumn($table,$column)
{
return"ALTERTABLE".$this->quoteTableName($table)
."DROPCOLUMN".$this->quoteColumnName($column);
}

Builds a SQL statement for dropping a DB column.

dropForeignKey() 方法 (可用自 v1.1.6)
public string dropForeignKey(string $name, string $table)
$namestringthe name of the foreign key constraint to be dropped. The name will be properly quoted by the method.
$tablestringthe table whose foreign is to be dropped. The name will be properly quoted by the method.
{return}stringthe SQL statement for dropping a foreign key constraint.
源码: framework/db/schema/CDbSchema.php#520 (显示) publicfunctiondropForeignKey($name,$table)
{
return'ALTERTABLE'.$this->quoteTableName($table)
.'DROPCONSTRAINT'.$this->quoteColumnName($name);
}

Builds a SQL statement for dropping a foreign key constraint.

dropIndex() 方法 (可用自 v1.1.6)
public string dropIndex(string $name, string $table)
$namestringthe name of the index to be dropped. The name will be properly quoted by the method.
$tablestringthe table whose index is to be dropped. The name will be properly quoted by the method.
{return}stringthe SQL statement for dropping an index.
源码: framework/db/schema/CDbSchema.php#559 (显示) publicfunctiondropIndex($name,$table)
{
return'DROPINDEX'.$this->quoteTableName($name).'ON'.$this->quoteTableName($table);
}

Builds a SQL statement for dropping an index.

dropTable() 方法 (可用自 v1.1.6)
public string dropTable(string $table)
$tablestringthe table to be dropped. The name will be properly quoted by the method.
{return}stringthe SQL statement for dropping a DB table.
源码: framework/db/schema/CDbSchema.php#401 (显示) publicfunctiondropTable($table)
{
return"DROPTABLE".$this->quoteTableName($table);
}

Builds a SQL statement for dropping a DB table.

findTableNames() 方法
protected array findTableNames(string $schema='')
$schemastringthe schema of the tables. Defaults to empty string, meaning the current or default schema. If not empty, the returned table names will be prefixed with the schema name.
{return}arrayall table names in the database.
源码: framework/db/schema/CDbSchema.php#306 (显示) protectedfunctionfindTableNames($schema='')
{
thrownewCDbException(Yii::t('yii','{class}doesnotsupportfetchingalltablenames.',
array('{class}'=>get_class($this))));
}

Returns all table names in the database. This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.

getColumnType() 方法 (可用自 v1.1.6)
public string getColumnType(string $type)
$typestringabstract column type
{return}stringphysical column type.
源码: framework/db/schema/CDbSchema.php#339 (显示) publicfunctiongetColumnType($type)
{
if(isset($this->columnTypes[$type]))
return$this->columnTypes[$type];
elseif(($pos=strpos($type,''))!==false)
{
$t=substr($type,0,$pos);
return(isset($this->columnTypes[$t])?$this->columnTypes[$t]:$t).substr($type,$pos);
}
else
return$type;
}

Converts an abstract column type into a physical column type. The conversion is done using the type map specified in columnTypes. These abstract column types are supported (using MySQL as example to explain the corresponding physical types):

  • pk: an auto-incremental primary key type, will be converted into "int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY"
  • string: string type, will be converted into "varchar(255)"
  • text: a long string type, will be converted into "text"
  • integer: integer type, will be converted into "int(11)"
  • boolean: boolean type, will be converted into "tinyint(1)"
  • float: float number type, will be converted into "float"
  • decimal: decimal number type, will be converted into "decimal"
  • datetime: datetime type, will be converted into "datetime"
  • timestamp: timestamp type, will be converted into "timestamp"
  • time: time type, will be converted into "time"
  • date: date type, will be converted into "date"
  • binary: binary data type, will be converted into "blob"


If the abstract type contains two or more parts separated by spaces (e.g. "string NOT NULL"), then only the first part will be converted, and the rest of the parts will be appended to the conversion result. For example, 'string NOT NULL' is converted to 'varchar(255) NOT NULL'.

getCommandBuilder() 方法
public CDbCommandBuilder getCommandBuilder()
{return}CDbCommandBuilderthe SQL command builder for this connection.
源码: framework/db/schema/CDbSchema.php#147 (显示) publicfunctiongetCommandBuilder()
{
if($this->_builder!==null)
return$this->_builder;
else
return$this->_builder=$this->createCommandBuilder();
}
getDbConnection() 方法
public CDbConnection getDbConnection()
{return}CDbConnectiondatabase connection. The connection is active.
源码: framework/db/schema/CDbSchema.php#61 (显示) publicfunctiongetDbConnection()
{
return$this->_connection;
}
getTable() 方法
public CDbTableSchema getTable(string $name, boolean $refresh=false)
$namestringtable name
$refreshbooleanif we need to refresh schema cache for a table. Parameter available since 1.1.9
{return}CDbTableSchematable metadata. Null if the named table does not exist.
源码: framework/db/schema/CDbSchema.php#73 (显示) publicfunctiongetTable($name,$refresh=false)
{
if($refresh===false&&isset($this->_tables[$name]))
return$this->_tables[$name];
else
{
if($this->_connection->tablePrefix!==null&&strpos($name,'{{')!==false)
$realName=preg_replace('/{{(.*?)}}/',$this->_connection->tablePrefix.'$1',$name);
else
$realName=$name;

//temporarilydisablequerycaching
if($this->_connection->queryCachingDuration>0)
{
$qcDuration=$this->_connection->queryCachingDuration;
$this->_connection->queryCachingDuration=0;
}

if(!isset($this->_cacheExclude[$name])&&($duration=$this->_connection->schemaCachingDuration)>0&&$this->_connection->schemaCacheID!==false&&($cache=Yii::app()->getComponent($this->_connection->schemaCacheID))!==null)
{
$key='yii:dbschema'.$this->_connection->connectionString.':'.$this->_connection->username.':'.$name;
$table=$cache->get($key);
if($refresh===true||$table===false)
{
$table=$this->loadTable($realName);
if($table!==null)
$cache->set($key,$table,$duration);
}
$this->_tables[$name]=$table;
}
else
$this->_tables[$name]=$table=$this->loadTable($realName);

if(isset($qcDuration))//re-enablequerycaching
$this->_connection->queryCachingDuration=$qcDuration;

return$table;
}
}

Obtains the metadata for the named table.

getTableNames() 方法
public array getTableNames(string $schema='')
$schemastringthe schema of the tables. Defaults to empty string, meaning the current or default schema. If not empty, the returned table names will be prefixed with the schema name.
{return}arrayall table names in the database.
源码: framework/db/schema/CDbSchema.php#137 (显示) publicfunctiongetTableNames($schema='')
{
if(!isset($this->_tableNames[$schema]))
$this->_tableNames[$schema]=$this->findTableNames($schema);
return$this->_tableNames[$schema];
}

Returns all table names in the database.

getTables() 方法
public array getTables(string $schema='')
$schemastringthe schema of the tables. Defaults to empty string, meaning the current or default schema.
{return}arraythe metadata for all tables in the database. Each array element is an instance of CDbTableSchema (or its child class). The array keys are table names.
源码: framework/db/schema/CDbSchema.php#120 (显示) publicfunctiongetTables($schema='')
{
$tables=array();
foreach($this->getTableNames($schema)as$name)
{
if(($table=$this->getTable($name))!==null)
$tables[$name]=$table;
}
return$tables;
}

Returns the metadata for all tables in the database.

loadTable() 方法
abstract protected CDbTableSchema loadTable(string $name)
$namestringtable name
{return}CDbTableSchemadriver dependent table metadata, null if the table does not exist.
源码: framework/db/schema/CDbSchema.php#45 (显示) abstractprotectedfunctionloadTable($name);

Loads the metadata for the specified table.

quoteColumnName() 方法
public string quoteColumnName(string $name)
$namestringcolumn name
{return}stringthe properly quoted column name
源码: framework/db/schema/CDbSchema.php#215 (显示) publicfunctionquoteColumnName($name)
{
if(($pos=strrpos($name,'.'))!==false)
{
$prefix=$this->quoteTableName(substr($name,0,$pos)).'.';
$name=substr($name,$pos+1);
}
else
$prefix='';
return$prefix.($name==='*'?$name:$this->quoteSimpleColumnName($name));
}

Quotes a column name for use in a query. If the column name contains prefix, the prefix will also be properly quoted.

参见

  • quoteSimpleColumnName
quoteSimpleColumnName() 方法 (可用自 v1.1.6)
public string quoteSimpleColumnName(string $name)
$namestringcolumn name
{return}stringthe properly quoted column name
源码: framework/db/schema/CDbSchema.php#234 (显示) publicfunctionquoteSimpleColumnName($name)
{
return'"'.$name.'"';
}

Quotes a simple column name for use in a query. A simple column name does not contain prefix.

quoteSimpleTableName() 方法 (可用自 v1.1.6)
public string quoteSimpleTableName(string $name)
$namestringtable name
{return}stringthe properly quoted table name
源码: framework/db/schema/CDbSchema.php#203 (显示) publicfunctionquoteSimpleTableName($name)
{
return"'".$name."'";
}

Quotes a simple table name for use in a query. A simple table name does not schema prefix.

quoteTableName() 方法
public string quoteTableName(string $name)
$namestringtable name
{return}stringthe properly quoted table name
源码: framework/db/schema/CDbSchema.php#185 (显示) publicfunctionquoteTableName($name)
{
if(strpos($name,'.')===false)
return$this->quoteSimpleTableName($name);
$parts=explode('.',$name);
foreach($partsas$i=>$part)
$parts[$i]=$this->quoteSimpleTableName($part);
returnimplode('.',$parts);

}

Quotes a table name for use in a query. If the table name contains schema prefix, the prefix will also be properly quoted.

参见

  • quoteSimpleTableName
refresh() 方法
public void refresh()
源码: framework/db/schema/CDbSchema.php#160 (显示) publicfunctionrefresh()
{
if(($duration=$this->_connection->schemaCachingDuration)>0&&$this->_connection->schemaCacheID!==false&&($cache=Yii::app()->getComponent($this->_connection->schemaCacheID))!==null)
{
foreach(array_keys($this->_tables)as$name)
{
if(!isset($this->_cacheExclude[$name]))
{
$key='yii:dbschema'.$this->_connection->connectionString.':'.$this->_connection->username.':'.$name;
$cache->delete($key);
}
}
}
$this->_tables=array();
$this->_tableNames=array();
$this->_builder=null;
}

Refreshes the schema. This method resets the loaded table metadata and command builder so that they can be recreated to reflect the change of schema.

renameColumn() 方法 (可用自 v1.1.6)
public string renameColumn(string $table, string $name, string $newName)
$tablestringthe table whose column is to be renamed. The name will be properly quoted by the method.
$namestringthe old name of the column. The name will be properly quoted by the method.
$newNamestringthe new name of the column. The name will be properly quoted by the method.
{return}stringthe SQL statement for renaming a DB column.
源码: framework/db/schema/CDbSchema.php#455 (显示) publicfunctionrenameColumn($table,$name,$newName)
{
return"ALTERTABLE".$this->quoteTableName($table)
."RENAMECOLUMN".$this->quoteColumnName($name)
."TO".$this->quoteColumnName($newName);
}

Builds a SQL statement for renaming a column.

renameTable() 方法 (可用自 v1.1.6)
public string renameTable(string $table, string $newName)
$tablestringthe table to be renamed. The name will be properly quoted by the method.
$newNamestringthe new table name. The name will be properly quoted by the method.
{return}stringthe SQL statement for renaming a DB table.
源码: framework/db/schema/CDbSchema.php#390 (显示) publicfunctionrenameTable($table,$newName)
{
return'RENAMETABLE'.$this->quoteTableName($table).'TO'.$this->quoteTableName($newName);
}

Builds a SQL statement for renaming a DB table.

resetSequence() 方法 (可用自 v1.1)
public void resetSequence(CDbTableSchema $table, mixed $value=NULL)
$tableCDbTableSchemathe table schema whose primary key sequence will be reset
$valuemixedthe 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 a value 1.
源码: framework/db/schema/CDbSchema.php#274 (显示) publicfunctionresetSequence($table,$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 1.

truncateTable() 方法 (可用自 v1.1.6)
public string truncateTable(string $table)
$tablestringthe table to be truncated. The name will be properly quoted by the method.
{return}stringthe SQL statement for truncating a DB table.
源码: framework/db/schema/CDbSchema.php#412 (显示) publicfunctiontruncateTable($table)
{
return"TRUNCATETABLE".$this->quoteTableName($table);
}

Builds a SQL statement for truncating a DB table.