lithium\data\source\database\adapter\MySql::_execute()
Implements
lithium\data\source\Database::_execute()
Execute a given query.
Parameters
-
string
$sql
The sql string to execute
-
array
$options
Available options:
- 'buffered': If set to
false
uses mysql_unbuffered_query which sends the SQL query query to MySQL without automatically fetching and buffering the result rows asmysql_query()
does (for less memory usage).
- 'buffered': If set to
Returns
\lithium\data\source\ResultReturns a result object if the query was successful.
Filter
This method can be filtered.
Source
protected function _execute($sql, array $options = []) {
$defaults = ['buffered' => true];
$options += $defaults;
$params = compact('sql', 'options');
return Filters::run($this, __FUNCTION__, $params, function($params) {
$this->connection->setAttribute(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,
$params['options']['buffered']
);
try {
$resource = $this->connection->query($params['sql']);
} catch (PDOException $e) {
$this->_error($params['sql']);
};
return Libraries::instance(null, 'result', compact('resource'), $this->_classes);
});
}