PHP 클래스 Prado\Data\TDbCommand

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.
부터: 3.0
저자: Qiang Xue ([email protected])
상속: extends Prado\TComponent
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( TDbConnection $connection, $text ) Constructor.
__sleep ( ) Set the statement to null when serializing.
bindParameter ( $name, &$value, $dataType = null, $length = null ) Binds a parameter to the SQL statement to be executed.
bindValue ( $name, $value, $dataType = null ) Binds a value to a parameter.
cancel ( ) Cancels the execution of the SQL statement.
execute ( ) : integer Executes the SQL statement.
getConnection ( ) : TDbConnection
getDebugStatementText ( ) : String
getPdoStatement ( ) : PDOStatement
getText ( ) : string
prepare ( ) Prepares the SQL statement to be executed.
query ( ) : TDbDataReader Executes the SQL statement and returns query result.
queryColumn ( ) : array Executes the SQL statement and returns the first column of the result.
queryRow ( $fetchAssociative = true ) : array Executes the SQL statement and returns the first row of the result.
queryScalar ( ) : mixed Executes the SQL statement and returns the value of the first column in the first row of data.
setText ( $value ) Specifies the SQL statement to be executed.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( TDbConnection $connection, $text )
$connection TDbConnection

__sleep() 공개 메소드

Set the statement to null when serializing.
public __sleep ( )

bindParameter() 공개 메소드

Binds a parameter to the SQL statement to be executed.
또한 보기: http://www.php.net/manual/en/function.PDOStatement-bindParam.php
public bindParameter ( $name, &$value, $dataType = null, $length = null )

bindValue() 공개 메소드

Binds a value to a parameter.
또한 보기: http://www.php.net/manual/en/function.PDOStatement-bindValue.php
public bindValue ( $name, $value, $dataType = null )

cancel() 공개 메소드

Cancels the execution of the SQL statement.
public cancel ( )

execute() 공개 메소드

This method is meant only for executing non-query SQL statement. No result set will be returned.
public execute ( ) : integer
리턴 integer number of rows affected by the execution.

getConnection() 공개 메소드

public getConnection ( ) : TDbConnection
리턴 TDbConnection the connection associated with this command

getDebugStatementText() 공개 메소드

public getDebugStatementText ( ) : String
리턴 String prepared SQL text for debugging purposes.

getPdoStatement() 공개 메소드

public getPdoStatement ( ) : PDOStatement
리턴 PDOStatement the underlying PDOStatement for this command It could be null if the statement is not prepared yet.

getText() 공개 메소드

public getText ( ) : string
리턴 string the SQL statement to be executed

prepare() 공개 메소드

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 prepare ( )

query() 공개 메소드

This method is for executing an SQL query that returns result set.
public query ( ) : TDbDataReader
리턴 TDbDataReader the reader object for fetching the query result

queryColumn() 공개 메소드

This is a convenient method of {@link query} when only the first column of data is needed. Note, the column returned will contain the first element in each row of result.
부터: 3.1.2
public queryColumn ( ) : array
리턴 array the first column of the query result. Empty array if no result.

queryRow() 공개 메소드

This is a convenient method of {@link query} when only the first row of data is needed.
public queryRow ( $fetchAssociative = true ) : array
리턴 array the first row of the query result, false if no result.

queryScalar() 공개 메소드

This is a convenient method of {@link query} when only a single scalar value is needed (e.g. obtaining the count of the records).
public queryScalar ( ) : mixed
리턴 mixed the value of the first column in the first row of the query result. False is returned if there is no value.

setText() 공개 메소드

Any previous execution will be terminated or cancel.
public setText ( $value )