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');
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$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