mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Included an option to configure the prepate statement. SQL Server requires the cursor option to return the affected rows.
This commit is contained in:
parent
11d249e43b
commit
968fa1d5ef
2 changed files with 18 additions and 2 deletions
|
@ -689,4 +689,19 @@ class Mssql extends DboSource {
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -450,10 +450,11 @@ class DboSource extends DataSource {
|
|||
*
|
||||
* @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 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
try {
|
||||
$query = $this->_connection->prepare($sql);
|
||||
$query = $this->_connection->prepare($sql, $prepareOptions);
|
||||
$query->setFetchMode(PDO::FETCH_LAZY);
|
||||
if (!$query->execute($params)) {
|
||||
$this->_results = $query;
|
||||
|
|
Loading…
Reference in a new issue