TDbCommand represents an SQL statement to execute against a database. It is usually created by calling {@link TDbConnection::createCommand}. The SQL statement to be executed may be set via {@link setText Text}. To execute a non-query SQL (such as insert, delete, update), call {@link execute}. To execute an SQL statement that returns result data set (such as select), use {@link query} or its convenient versions {@link queryRow} and {@link queryScalar}. If an SQL statement returns results (such as a SELECT SQL), the results can be accessed via the returned {@link TDbDataReader}. TDbCommand supports SQL statment preparation and parameter binding. Call {@link bindParameter} to bind a PHP variable to a parameter in SQL. Call {@link bindValue} to bind a value to an SQL parameter. When binding a parameter, the SQL statement is automatically prepared. You may also call {@link prepare} to explicitly prepare an SQL statement.
Since: 3.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Prado\TComponent
示例#1
0
 /**
  * Constructor.
  * @param TDbCommand the command generating the query result
  */
 public function __construct(TDbCommand $command)
 {
     $this->_statement = $command->getPdoStatement();
     $this->_statement->setFetchMode(PDO::FETCH_ASSOC);
 }