lithium\data\source\database\adapter\MySql::_execute()

protected method

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 as mysql_query() does (for less memory usage).

Returns

\lithium\data\source\Result

Returns a result object if the query was successful.

Filter

This method can be filtered.

Source

	protected function _execute($sql, array $options = array()) {
		$defaults = array('buffered' => true);
		$options += $defaults;

		$conn = $this->connection;

		$params = compact('sql', 'options');

		return $this->_filter(__METHOD__, $params, function($self, $params) use ($conn) {
			$sql = $params['sql'];
			$options = $params['options'];
			$conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $options['buffered']);

			try {
				$resource = $conn->query($sql);
			} catch (PDOException $e) {
				$self->invokeMethod('_error', array($sql));
			};
			return $self->invokeMethod('_instance', array('result', compact('resource')));
		});
	}