system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CDbSchema

system.db.schema
继承 abstract class CDbSchema » CComponent
子类 CMssqlSchema, CMysqlSchema, COciSchema, CPgsqlSchema, CSqliteSchema
可用自 1.0
版本 $Id$
CDbSchema is the base class for retrieving metadata information.

公共属性

隐藏继承的属性

属性类型描述被定义在
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() Calls the named method which is not a class method. CComponent
__construct() Constructor. CDbSchema
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
compareTableNames() Compares two table names. CDbSchema
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
getCommandBuilder() CDbSchema
getDbConnection() CDbSchema
getEventHandlers() Returns the list of attached event handlers for an event. 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() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
quoteColumnName() Quotes a column name for use in a query. CDbSchema
quoteTableName() Quotes a table name for use in a query. CDbSchema
raiseEvent() Raises an event. CComponent
refresh() Refreshes the schema. CDbSchema

受保护的方法

隐藏继承的方法

方法描述被定义在
createCommandBuilder() Creates a command builder for the database. CDbSchema
createTable() Creates a table instance representing the metadata for the named table. CDbSchema
findTableNames() Returns all table names in the database. CDbSchema

属性详情

commandBuilder 属性 只读

the SQL command builder for this connection.

dbConnection 属性 只读

database connection. The connection is active.

tableNames 属性 只读 (自版本 v1.0.2 可用)
public array getTableNames(string $schema='')

Returns all table names in the database.

tables 属性 只读 (自版本 v1.0.2 可用)
public array getTables(string $schema='')

Returns the metadata for all tables in the database.

方法详情

__construct() 方法
public void __construct(CDbConnection $conn)
$conn CDbConnection database connection.

Constructor.

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.

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

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

createTable() 方法
abstract protected CDbTableSchema createTable($name)
$name
{return} CDbTableSchema driver dependent table metadata, null if the table does not exist.

Creates a table instance representing the metadata for the named table.

findTableNames() 方法 (自版本 v1.0.2 可用)
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.

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

getCommandBuilder() 方法
public CDbCommandBuilder getCommandBuilder()
{return} CDbCommandBuilder the SQL command builder for this connection.

getDbConnection() 方法
public CDbConnection getDbConnection()
{return} CDbConnection database connection. The connection is active.

getTable() 方法
public CDbTableSchema getTable(string $name)
$name string table name
{return} CDbTableSchema table metadata. Null if the named table does not exist.

Obtains the metadata for the named table.

getTableNames() 方法 (自版本 v1.0.2 可用)
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.

Returns all table names in the database.

getTables() 方法 (自版本 v1.0.2 可用)
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.

Returns the metadata for all tables in the database.

quoteColumnName() 方法
public string quoteColumnName(string $name)
$name string column name
{return} string the properly quoted column name

Quotes a column name for use in a query.

quoteTableName() 方法
public string quoteTableName(string $name)
$name string table name
{return} string the properly quoted table name

Quotes a table name for use in a query.

refresh() 方法
public void refresh()

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.