diff --git a/lib/Cake/Model/Datasource/Database/Mssql.php b/lib/Cake/Model/Datasource/Database/Mssql.php index b27b8cb18ff..db390bf12bf 100644 --- a/lib/Cake/Model/Datasource/Database/Mssql.php +++ b/lib/Cake/Model/Datasource/Database/Mssql.php @@ -689,4 +689,19 @@ protected function _getPrimaryKey($model) { } return null; } + +/** + * Executes given SQL statement. + * + * @param string $sql SQL statement + * @param array $params list of params to be bound to query + * @param array $prepareOptions Options to be used in the prepare statement + * @return PDOStatement if query executes with no problem, true as the result of a succesfull + * query returning no rows, suchs as a CREATE statement, false otherwise + */ + protected function _execute($sql, $params = array(), $prepareOptions = array()) { + $prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL); + return parent::_execute($sql, $params, $prepareOptions); + } + } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 8d3db098b42..b40c682a3f6 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -450,10 +450,11 @@ public function execute($sql, $options = array(), $params = array()) { * * @param string $sql SQL statement * @param array $params list of params to be bound to query + * @param array $prepareOptions Options to be used in the prepare statement * @return PDOStatement if query executes with no problem, true as the result of a succesfull * query returning no rows, suchs as a CREATE statement, false otherwise */ - protected function _execute($sql, $params = array()) { + protected function _execute($sql, $params = array(), $prepareOptions = array()) { $sql = trim($sql); if (preg_match('/^(?:CREATE|ALTER|DROP)/i', $sql)) { $statements = array_filter(explode(';', $sql)); @@ -464,7 +465,7 @@ protected function _execute($sql, $params = array()) { } try { - $query = $this->_connection->prepare($sql); + $query = $this->_connection->prepare($sql, $prepareOptions); $query->setFetchMode(PDO::FETCH_LAZY); if (!$query->execute($params)) { $this->_results = $query;