DbCommand

Type
Class
Namespace
Craft
Inherits
Craft\DbCommand » CDbCommand » CComponent
Since
1.0

Class DbCommand

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$paramsarray – The parameters (name=>value) to be bound to the current query.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__sleep()Set the statement to null when serializing.
__unset()Sets a component property to be null.
addColumn()
addColumnAfter()
addColumnBefore()
addColumnFirst()
addForeignKey()
addOrder()
addPrimaryKey()
addSelect()Adds additional select columns.
alterColumn()
andWhere()Adds an additional "and where" condition.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
bindParam()Binds a parameter to the SQL statement to be executed.
bindValue()Binds a value to a parameter.
bindValues()Binds a list of values to the corresponding parameters.
buildQuery()Builds a SQL SELECT statement from the given query specification.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
cancel()Cancels the execution of the SQL statement.
count()Returns the total number of rows matched by the query.
createIndex()
createTable()Adds id, dateCreated, date_update, and uid columns to $columns, packages up the column definitions into strings, and then passes it back to CDbCommand->createTable().
crossJoin()
delete()
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
dropColumn()
dropForeignKey()
dropIndex()
dropPrimaryKey()
dropTable()
dropTableIfExists()
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
execute()Executes the SQL statement.
from()
getConnection()
getDistinct()Returns a value indicating whether SELECT DISTINCT should be used.
getEventHandlers()Returns the list of attached event handlers for an event.
getFrom()Returns the FROM part in the query.
getGroup()Returns the GROUP BY part in the query.
getHaving()Returns the HAVING part in the query.
getJoin()Returns the join part in the query.
getJoinedTables()Returns the tables that have been joined.
getLimit()Returns the LIMIT part in the query.
getOffset()Returns the OFFSET part in the query.
getOrder()Returns the ORDER BY part in the query.
getPdoStatement()
getSelect()Returns the SELECT part in the query.
getText()
getUnion()Returns the UNION part in the query.
getWhere()Returns the WHERE part in the query.
group()Sets the GROUP BY part of the query.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
having()
insert()
insertAll()
insertOrUpdate()
isJoined()Returns whether a given table has been joined in this query.
join()
leftJoin()
limit()Sets the LIMIT part of the query.
naturalJoin()
naturalLeftJoin()
naturalRightJoin()
offset()Sets the OFFSET part of the query.
orWhere()Adds an additional "or where" condition.
order()Sets the ORDER BY part of the query.
prepare()Prepares the SQL statement to be executed.
query()Executes the SQL statement and returns query result.
queryAll()Executes the SQL statement and returns all rows.
queryColumn()Executes the SQL statement and returns the first column of the result.
queryRow()Executes the SQL statement and returns the first row of the result.
queryScalar()Executes the SQL statement and returns the value of the first column in the first row of data.
raiseEvent()Raises an event.
renameColumn()
renameTable()
replace()
reset()Cleans up the command and prepares for building a new query.
rightJoin()
select()Sets the SELECT part of the query.
selectDistinct()Sets the SELECT part of the query with the DISTINCT flag turned on.
setDistinct()Sets a value indicating whether SELECT DISTINCT should be used.
setFetchMode()Set the default fetch mode for this statement
setFrom()Sets the FROM part in the query.
setGroup()Sets the GROUP BY part in the query.
setHaving()Sets the HAVING part in the query.
setJoin()Sets the join part in the query.
setLimit()Sets the LIMIT part in the query.
setOffset()Sets the OFFSET part in the query.
setOrder()Sets the ORDER BY part in the query.
setSelect()Sets the SELECT part in the query.
setText()Specifies the SQL statement to be executed.
setUnion()Sets the UNION part in the query.
setWhere()Sets the WHERE part in the query.
truncateTable()
union()Appends a SQL statement using UNION operator.
update()
where()

__construct()

Constructor

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand __construct ( CDbConnection $connection, $query = null )

addColumn()

View source

Arguments

  • $table
  • $column
  • $type

Returns

mixed

Signature

public mixed addColumn ( $table, $column, $type )

addColumnAfter()

View source

Arguments

  • $table
  • $column
  • $type
  • $after

Returns

mixed

Signature

public mixed addColumnAfter ( $table, $column, $type, $after )

addColumnBefore()

View source

Arguments

  • $table
  • $column
  • $type
  • $before

Returns

mixed

Signature

public mixed addColumnBefore ( $table, $column, $type, $before )

addColumnFirst()

View source

Arguments

  • $table
  • $column
  • $type

Returns

mixed

Signature

public mixed addColumnFirst ( $table, $column, $type )

addForeignKey()

View source

Arguments

  • $table
  • $columns
  • $refTable
  • $refColumns
  • $delete (null)
  • $update (null)

Returns

integer

Signature

public integer addForeignKey ( $table, $columns, $refTable, $refColumns, $delete = null, $update = null )

addOrder()

View source

Arguments

  • $columns (mixed)

Returns

Craft\DbCommand

Signature

public Craft\DbCommand addOrder ( $columns )

addPrimaryKey()

View source

Arguments

Returns

integer

Signature

public integer addPrimaryKey ( $table, $columns )

addSelect()

Adds additional select columns.

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand addSelect ( $columns = '*' )

alterColumn()

View source

Arguments

  • $table
  • $column
  • $type
  • $newName (null)
  • $after (null)

Returns

integer

Signature

public integer alterColumn ( $table, $column, $type, $newName = null, $after = null )

andWhere()

Adds an additional "and where" condition.

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand andWhere ( $conditions, $params = [] )

count()

Returns the total number of rows matched by the query.

View source

Arguments

  • $column (string) – The column to count.

Returns

integer – The total number of rows matched by the query.

Signature

public integer count ( $column )

createIndex()

View source

Arguments

Returns

integer

Signature

public integer createIndex ( $table, $columns, $unique = false )

createTable()

Adds id, dateCreated, date_update, and uid columns to $columns, packages up the column definitions into strings, and then passes it back to CDbCommand->createTable().

View source

Arguments

Returns

integer

Signature

public integer createTable ( $table, $columns, $options = null, $addIdColumn = true, $addAuditColumns = true )

crossJoin()

View source

Arguments

  • $table

Returns

Craft\DbCommand

Signature

public Craft\DbCommand crossJoin ( $table )

delete()

View source

Arguments

Returns

integer

Signature

public integer delete ( $table, $conditions = '', $params = [] )

dropColumn()

View source

Arguments

  • $table
  • $column

Returns

integer

Signature

public integer dropColumn ( $table, $column )

dropForeignKey()

View source

Arguments

Returns

integer

Signature

public integer dropForeignKey ( $table, $columns )

dropIndex()

View source

Arguments

Returns

integer

Signature

public integer dropIndex ( $table, $columns, $unique = false )

dropPrimaryKey()

View source

Arguments

Returns

integer

Signature

public integer dropPrimaryKey ( $table, $columns )

dropTable()

View source

Arguments

  • $table

Returns

integer

Signature

public integer dropTable ( $table )

dropTableIfExists()

View source

Arguments

  • $table

Returns

integer

Signature

public integer dropTableIfExists ( $table )

from()

View source

Arguments

  • $tables

Returns

CDbCommand

Signature

public CDbCommand from ( $tables )

getJoinedTables()

Returns the tables that have been joined.

View source

Returns

array

Signature

public array getJoinedTables ( )

having()

View source

Arguments

  • $conditions (mixed)
  • $params (array)

Returns

Craft\DbCommand

Signature

public Craft\DbCommand having ( $conditions, $params = [] )

insert()

View source

Arguments

Returns

integer

Signature

public integer insert ( $table, $columns, $includeAuditColumns = true )

insertAll()

View source

Arguments

Returns

integer

Signature

public integer insertAll ( $table, $columns, $rows, $includeAuditColumns = true )

insertOrUpdate()

View source

Arguments

Returns

integer

Signature

public integer insertOrUpdate ( $table, $keyColumns, $updateColumns, $includeAuditColumns = true )

isJoined()

Returns whether a given table has been joined in this query.

View source

Arguments

Returns

boolean

Signature

public boolean isJoined ( $table )

join()

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand join ( $table, $conditions, $params = [] )

leftJoin()

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand leftJoin ( $table, $conditions, $params = [] )

naturalJoin()

View source

Arguments

  • $table

Returns

Craft\DbCommand

Signature

public Craft\DbCommand naturalJoin ( $table )

naturalLeftJoin()

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand naturalLeftJoin ( $table )

naturalRightJoin()

View source

Arguments

Returns

CDbCommand

Signature

public CDbCommand naturalRightJoin ( $table )

orWhere()

Adds an additional "or where" condition.

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand orWhere ( $conditions, $params = [] )

renameColumn()

View source

Arguments

  • $table
  • $name
  • $newName

Returns

integer

Signature

public integer renameColumn ( $table, $name, $newName )

renameTable()

View source

Arguments

  • $table
  • $newName

Returns

integer

Signature

public integer renameTable ( $table, $newName )

replace()

View source

Arguments

Returns

integer

Signature

public integer replace ( $table, $column, $find, $replace )

rightJoin()

View source

Arguments

Returns

Craft\DbCommand

Signature

public Craft\DbCommand rightJoin ( $table, $conditions, $params = [] )

truncateTable()

View source

Arguments

  • $table

Returns

integer

Signature

public integer truncateTable ( $table )

update()

View source

Arguments

Returns

integer

Signature

public integer update ( $table, $columns, $conditions = '', $params = [], $includeAuditColumns = true )

where()

View source

Arguments

  • $conditions (mixed)
  • $params (array)

Returns

Craft\DbCommand

Signature

public Craft\DbCommand where ( $conditions, $params = [] )