Yii Framework v1.1.10 绫诲弬鑰

CDbSchema

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.

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
columnTypes array the abstract column types mapped to physical column types. CDbSchema
commandBuilder CDbCommandBuilder the SQL command builder for this connection. CDbSchema
dbConnection CDbConnection database connection. CDbSchema
tableNames array Returns all table names in the database. CDbSchema
tables array Returns 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() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 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 灞炴 鍙

the SQL command builder for this connection.

dbConnection 灞炴 鍙

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)
$conn CDbConnection database connection.
婧愮爜锛 framework/db/schema/CDbSchema.php#51 (鏄剧ず)
public function __construct($conn)
{
    
$this->_connection=$conn;
    foreach(
$conn->schemaCachingExclude as $name)
        
$this->_cacheExclude[$name]=true;
}

Constructor.

addColumn() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.6锛
public string addColumn(string $table, string $column, string $type)
$table string the table that the new column will be added to. The table name will be properly quoted by the method.
$column string the name of the new column. The name will be properly quoted by the method.
$type string the 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} string the SQL statement for adding a new column.
婧愮爜锛 framework/db/schema/CDbSchema.php#427 (鏄剧ず)
public function addColumn($table$column$type)
{
    return 
'ALTER TABLE ' $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)
$name string the name of the foreign key constraint.
$table string the table that the foreign key constraint will be added to.
$columns string the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas.
$refTable string the table that the foreign key references to.
$refColumns string the name of the column that the foreign key references to. If there are multiple columns, separate them with commas.
$delete string the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
$update string the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
{return} string the SQL statement for adding a foreign key constraint to an existing table.
婧愮爜锛 framework/db/schema/CDbSchema.php#493 (鏄剧ず)
public function addForeignKey($name$table$columns$refTable$refColumns$delete=null$update=null)
{
    
$columns=preg_split('/\s*,\s*/',$columns,-1,PREG_SPLIT_NO_EMPTY);
    foreach(
$columns as $i=>$col)
        
$columns[$i]=$this->quoteColumnName($col);
    
$refColumns=preg_split('/\s*,\s*/',$refColumns,-1,PREG_SPLIT_NO_EMPTY);
    foreach(
$refColumns as $i=>$col)
        
$refColumns[$i]=$this->quoteColumnName($col);
    
$sql='ALTER TABLE '.$this->quoteTableName($table)
        .
' ADD CONSTRAINT '.$this->quoteColumnName($name)
        .
' FOREIGN KEY ('.implode(', '$columns).')'
        
.' REFERENCES '.$this->quoteTableName($refTable)
        .
' ('.implode(', '$refColumns).')';
    if(
$delete!==null)
        
$sql.=' ON DELETE '.$delete;
    if(
$update!==null)
        
$sql.=' ON UPDATE '.$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)
$table string the table whose column is to be changed. The table name will be properly quoted by the method.
$column string the name of the column to be changed. The name will be properly quoted by the method.
$type string the 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} string the SQL statement for changing the definition of a column.
婧愮爜锛 framework/db/schema/CDbSchema.php#472 (鏄剧ず)
public function alterColumn($table$column$type)
{
    return 
'ALTER TABLE ' $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='')
$check boolean whether to turn on or off the integrity check.
$schema string the schema of the tables. Defaults to empty string, meaning the current or default schema.
婧愮爜锛 framework/db/schema/CDbSchema.php#284 (鏄剧ず)
public function checkIntegrity($check=true,$schema='')
{
}

Enables or disables integrity check.

compareTableNames() 鏂规硶
public boolean compareTableNames(string $name1, string $name2)
$name1 string table name 1
$name2 string table name 2
{return} boolean whether the two table names refer to the same table.
婧愮爜锛 framework/db/schema/CDbSchema.php#247 (鏄剧ず)
public function compareTableNames($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} CDbCommandBuilder command builder instance
婧愮爜锛 framework/db/schema/CDbSchema.php#293 (鏄剧ず)
protected function createCommandBuilder()
{
    return new 
CDbCommandBuilder($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)
$name string the name of the index. The name will be properly quoted by the method.
$table string the table that the new index will be created for. The table name will be properly quoted by the method.
$column string the 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.
$unique boolean whether to add UNIQUE constraint on the created index.
{return} string the SQL statement for creating a new index.
婧愮爜锛 framework/db/schema/CDbSchema.php#536 (鏄剧ず)
public function createIndex($name$table$column$unique=false)
{
    
$cols=array();
    
$columns=preg_split('/\s*,\s*/',$column,-1,PREG_SPLIT_NO_EMPTY);
    foreach(
$columns as $col)
    {
        if(
strpos($col,'(')!==false)
            
$cols[]=$col;
        else
            
$cols[]=$this->quoteColumnName($col);
    }
    return (
$unique 'CREATE UNIQUE INDEX ' 'CREATE INDEX ')
        . 
$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)
$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.
婧愮爜锛 framework/db/schema/CDbSchema.php#369 (鏄剧ず)
public function createTable($table$columns$options=null)
{
    
$cols=array();
    foreach(
$columns as $name=>$type)
    {
        if(
is_string($name))
            
$cols[]="\t".$this->quoteColumnName($name).' '.$this->getColumnType($type);
        else
            
$cols[]="\t".$type;
    }
    
$sql="CREATE TABLE ".$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)
$table string the table whose column is to be dropped. The name will be properly quoted by the method.
$column string the name of the column to be dropped. The name will be properly quoted by the method.
{return} string the SQL statement for dropping a DB column.
婧愮爜锛 framework/db/schema/CDbSchema.php#441 (鏄剧ず)
public function dropColumn($table$column)
{
    return 
"ALTER TABLE ".$this->quoteTableName($table)
        .
" DROP COLUMN ".$this->quoteColumnName($column);
}

Builds a SQL statement for dropping a DB column.

dropForeignKey() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.6锛
public string dropForeignKey(string $name, string $table)
$name string the name of the foreign key constraint to be dropped. The name will be properly quoted by the method.
$table string the table whose foreign is to be dropped. The name will be properly quoted by the method.
{return} string the SQL statement for dropping a foreign key constraint.
婧愮爜锛 framework/db/schema/CDbSchema.php#520 (鏄剧ず)
public function dropForeignKey($name$table)
{
    return 
'ALTER TABLE '.$this->quoteTableName($table)
        .
' DROP CONSTRAINT '.$this->quoteColumnName($name);
}

Builds a SQL statement for dropping a foreign key constraint.

dropIndex() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.6锛
public string dropIndex(string $name, string $table)
$name string the name of the index to be dropped. The name will be properly quoted by the method.
$table string the table whose index is to be dropped. The name will be properly quoted by the method.
{return} string the SQL statement for dropping an index.
婧愮爜锛 framework/db/schema/CDbSchema.php#559 (鏄剧ず)
public function dropIndex($name$table)
{
    return 
'DROP INDEX '.$this->quoteTableName($name).' ON '.$this->quoteTableName($table);
}

Builds a SQL statement for dropping an index.

dropTable() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.6锛
public string dropTable(string $table)
$table string the table to be dropped. The name will be properly quoted by the method.
{return} string the SQL statement for dropping a DB table.
婧愮爜锛 framework/db/schema/CDbSchema.php#401 (鏄剧ず)
public function dropTable($table)
{
    return 
"DROP TABLE ".$this->quoteTableName($table);
}

Builds a SQL statement for dropping a DB table.

findTableNames() 鏂规硶
protected array findTableNames(string $schema='')
$schema string the 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} array all table names in the database.
婧愮爜锛 framework/db/schema/CDbSchema.php#306 (鏄剧ず)
protected function findTableNames($schema='')
{
    throw new 
CDbException(Yii::t('yii','{class} does not support fetching all table names.',
        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)
$type string abstract column type
{return} string physical column type.
婧愮爜锛 framework/db/schema/CDbSchema.php#339 (鏄剧ず)
public function getColumnType($type)
{
    if(isset(
$this->columnTypes[$type]))
        return 
$this->columnTypes[$type];
    else if((
$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):



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} CDbCommandBuilder the SQL command builder for this connection.
婧愮爜锛 framework/db/schema/CDbSchema.php#147 (鏄剧ず)
public function getCommandBuilder()
{
    if(
$this->_builder!==null)
        return 
$this->_builder;
    else
        return 
$this->_builder=$this->createCommandBuilder();
}

getDbConnection() 鏂规硶
public CDbConnection getDbConnection()
{return} CDbConnection database connection. The connection is active.
婧愮爜锛 framework/db/schema/CDbSchema.php#61 (鏄剧ず)
public function getDbConnection()
{
    return 
$this->_connection;
}

getTable() 鏂规硶
public CDbTableSchema getTable(string $name, boolean $refresh=false)
$name string table name
$refresh boolean if we need to refresh schema cache for a table. Parameter available since 1.1.9
{return} CDbTableSchema table metadata. Null if the named table does not exist.
婧愮爜锛 framework/db/schema/CDbSchema.php#73 (鏄剧ず)
public function getTable($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;

        
// temporarily disable query caching
        
if($this->_connection->queryCachingDuration>0)
        {
            
$qcDuration=$this->_connection->queryCachingDuration;
            
$this->_connection->queryCachingDuration=0;
        }

        if(!isset(
$this->_cacheExclude[$name]) && ($duration=$this->_connection->schemaCachingDuration)>&& $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-enable query caching
            
$this->_connection->queryCachingDuration=$qcDuration;

        return 
$table;
    }
}

Obtains the metadata for the named table.

getTableNames() 鏂规硶
public array getTableNames(string $schema='')
$schema string the 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} array all table names in the database.
婧愮爜锛 framework/db/schema/CDbSchema.php#137 (鏄剧ず)
public function getTableNames($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='')
$schema string the schema of the tables. Defaults to empty string, meaning the current or default schema.
{return} array the 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 (鏄剧ず)
public function getTables($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)
$name string table name
{return} CDbTableSchema driver dependent table metadata, null if the table does not exist.
婧愮爜锛 framework/db/schema/CDbSchema.php#45 (鏄剧ず)
abstract protected function loadTable($name);

Loads the metadata for the specified table.

quoteColumnName() 鏂规硶
public string quoteColumnName(string $name)
$name string column name
{return} string the properly quoted column name
婧愮爜锛 framework/db/schema/CDbSchema.php#215 (鏄剧ず)
public function quoteColumnName($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() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.6锛
public string quoteSimpleColumnName(string $name)
$name string column name
{return} string the properly quoted column name
婧愮爜锛 framework/db/schema/CDbSchema.php#234 (鏄剧ず)
public function quoteSimpleColumnName($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)
$name string table name
{return} string the properly quoted table name
婧愮爜锛 framework/db/schema/CDbSchema.php#203 (鏄剧ず)
public function quoteSimpleTableName($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)
$name string table name
{return} string the properly quoted table name
婧愮爜锛 framework/db/schema/CDbSchema.php#185 (鏄剧ず)
public function quoteTableName($name)
{
    if(
strpos($name,'.')===false)
        return 
$this->quoteSimpleTableName($name);
    
$parts=explode('.',$name);
    foreach(
$parts as $i=>$part)
        
$parts[$i]=$this->quoteSimpleTableName($part);
    return 
implode('.',$parts);

}

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

refresh() 鏂规硶
public void refresh()
婧愮爜锛 framework/db/schema/CDbSchema.php#160 (鏄剧ず)
public function refresh()
{
    if((
$duration=$this->_connection->schemaCachingDuration)>&& $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)
$table string the table whose column is to be renamed. The name will be properly quoted by the method.
$name string the old name of the column. The name will be properly quoted by the method.
$newName string the new name of the column. The name will be properly quoted by the method.
{return} string the SQL statement for renaming a DB column.
婧愮爜锛 framework/db/schema/CDbSchema.php#455 (鏄剧ず)
public function renameColumn($table$name$newName)
{
    return 
"ALTER TABLE ".$this->quoteTableName($table)
        . 
" RENAME COLUMN ".$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)
$table string the table to be renamed. The name will be properly quoted by the method.
$newName string the new table name. The name will be properly quoted by the method.
{return} string the SQL statement for renaming a DB table.
婧愮爜锛 framework/db/schema/CDbSchema.php#390 (鏄剧ず)
public function renameTable($table$newName)
{
    return 
'RENAME TABLE ' $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)
$table CDbTableSchema the table schema whose primary key sequence will be reset
$value mixed 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 a value 1.
婧愮爜锛 framework/db/schema/CDbSchema.php#274 (鏄剧ず)
public function resetSequence($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)
$table string the table to be truncated. The name will be properly quoted by the method.
{return} string the SQL statement for truncating a DB table.
婧愮爜锛 framework/db/schema/CDbSchema.php#412 (鏄剧ず)
public function truncateTable($table)
{
    return 
"TRUNCATE TABLE ".$this->quoteTableName($table);
}

Builds a SQL statement for truncating a DB table.

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.