Class TDbCommand
TDbCommand class.
TDbCommand represents an SQL statement to execute against a database. It is
usually created by calling TDbConnection::createCommand()
. The SQL
statement to be executed may be set via setText Text.
To execute a non-query SQL (such as insert, delete, update), call TDbCommand::execute()
. To execute an SQL statement that returns result data set (such as
select), use TDbCommand::query()
or its convenient versions TDbCommand::queryRow()
and
TDbCommand::queryScalar()
.
If an SQL statement returns results (such as a SELECT SQL), the results can
be accessed via the returned TDbDataReader
.
TDbCommand supports SQL statment preparation and parameter binding. Call
TDbCommand::bindParameter()
to bind a PHP variable to a parameter in SQL. Call TDbCommand::bindValue()
to bind a value to an SQL parameter. When binding a parameter, the
SQL statement is automatically prepared. You may also call TDbCommand::prepare()
to
explicitly prepare an SQL statement.
- TComponent
-
TDbCommand
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Data/TDbCommand.php
public
|
|
public
|
|
public
string
|
|
public
|
#
setText( string $value )
Specifies the SQL statement to be executed. Any previous execution will be terminated or cancel. |
public
|
|
public
PDOStatement
|
|
public
|
#
prepare( )
Prepares the SQL statement to be executed. For complex SQL statement that is to be executed multiple times, this may improve performance. For SQL statement with binding parameters, this method is invoked automatically. |
public
|
|
public
|
#
bindParameter( mixed $name, mixed & $value, integer $dataType = null, integer $length = null )
Binds a parameter to the SQL statement to be executed. |
public
|
|
public
integer
|
#
execute( )
Executes the SQL statement. This method is meant only for executing non-query SQL statement. No result set will be returned. |
public
String
|
|
public
|
#
query( )
Executes the SQL statement and returns query result. This method is for executing an SQL query that returns result set. |
public
array
|
#
queryRow( boolean $fetchAssociative = true )
Executes the SQL statement and returns the first row of the result. This is a
convenient method of |
public
mixed
|
#
queryScalar( )
Executes the SQL statement and returns the value of the first column in the
first row of data. This is a convenient method of |
public
array
|
#
queryColumn( )
Executes the SQL statement and returns the first column of the result. This
is a convenient method of |
GLOBAL_RAISE_EVENT_LISTENER
|