PHP 클래스 Contao\Database\Statement

The class creates the database queries replacing the wildcards and escaping the values. It then executes the query and returns a result object. Usage: $db = Database::getInstance(); $stmt = $db->prepare("SELECT * FROM tl_member WHERE city=?"); $stmt->limit(10); $res = $stmt->execute('London');
파일 보기 프로젝트 열기: contao/core-bundle 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$arrCache array Result cache
$blnDisableAutocommit boolean Autocommit indicator
$resConnection Doctrine\DBAL\Connection Connection ID
$statement Doctrine\DBAL\Driver\Statement Database statement
$strQuery string Query string

공개 메소드들

메소드 설명
__construct ( Doctrine\DBAL\Connection $resConnection, boolean $blnDisableAutocommit = false ) Validate the connection resource and store the query string
__get ( string $strKey ) : mixed | null Return an object property
execute ( ) : Result | object Execute the query and return the result object
executeCached ( ) : Result Always execute the query and add or replace an existing cache entry
executeUncached ( ) : Result Bypass the cache and always execute the query
explain ( ) : string Explain the current query
limit ( integer $intRows, integer $intOffset ) : Statement Handle limit and offset
prepare ( string $strQuery ) : Statement Prepare a query string so the following functions can handle it
query ( string $strQuery = '' ) : Result | Statement Directly send a query string to the database
set ( array $arrParams ) : Statement Autogenerate the SET/VALUES subpart of a query from an associative array

보호된 메소드들

메소드 설명
escapeParams ( array $arrValues ) : array Escape the values and serialize objects and arrays
replaceWildcards ( array $arrValues ) Replace the wildcards in the query string

메소드 상세

__construct() 공개 메소드

Validate the connection resource and store the query string
public __construct ( Doctrine\DBAL\Connection $resConnection, boolean $blnDisableAutocommit = false )
$resConnection Doctrine\DBAL\Connection The connection resource
$blnDisableAutocommit boolean Optionally disable autocommitting

__get() 공개 메소드

Return an object property
public __get ( string $strKey ) : mixed | null
$strKey string The property name
리턴 mixed | null The property value or null

escapeParams() 보호된 메소드

Escape the values and serialize objects and arrays
protected escapeParams ( array $arrValues ) : array
$arrValues array The values array
리턴 array The array with the escaped values

execute() 공개 메소드

Execute the query and return the result object
public execute ( ) : Result | object
리턴 Result | object The result object

executeCached() 공개 메소드

Always execute the query and add or replace an existing cache entry
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Database\Statement::execute() instead.
public executeCached ( ) : Result
리턴 Result The result object

executeUncached() 공개 메소드

Bypass the cache and always execute the query
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Database\Statement::execute() instead.
public executeUncached ( ) : Result
리턴 Result The result object

explain() 공개 메소드

Explain the current query
public explain ( ) : string
리턴 string The explanation string

limit() 공개 메소드

Handle limit and offset
public limit ( integer $intRows, integer $intOffset ) : Statement
$intRows integer The maximum number of rows
$intOffset integer The number of rows to skip
리턴 Statement The statement object

prepare() 공개 메소드

Prepare a query string so the following functions can handle it
public prepare ( string $strQuery ) : Statement
$strQuery string The query string
리턴 Statement The statement object

query() 공개 메소드

Directly send a query string to the database
public query ( string $strQuery = '' ) : Result | Statement
$strQuery string The query string
리턴 Result | Statement The result object or the statement object if there is no result set

replaceWildcards() 보호된 메소드

Replace the wildcards in the query string
protected replaceWildcards ( array $arrValues )
$arrValues array The values array

set() 공개 메소드

Usage: $set = array( 'firstname' => 'Leo', 'lastname' => 'Feyer' ); $stmt->prepare("UPDATE tl_member %s")->set($set);
public set ( array $arrParams ) : Statement
$arrParams array The associative array
리턴 Statement The statement object

프로퍼티 상세

$arrCache 보호되어 있는 정적으로 프로퍼티

Result cache
protected static array $arrCache
리턴 array

$blnDisableAutocommit 보호되어 있는 프로퍼티

Autocommit indicator
protected bool $blnDisableAutocommit
리턴 boolean

$resConnection 보호되어 있는 프로퍼티

Connection ID
protected Connection,Doctrine\DBAL $resConnection
리턴 Doctrine\DBAL\Connection

$statement 보호되어 있는 프로퍼티

Database statement
protected Statement,Doctrine\DBAL\Driver $statement
리턴 Doctrine\DBAL\Driver\Statement

$strQuery 보호되어 있는 프로퍼티

Query string
protected string $strQuery
리턴 string