Included an option to configure the prepate statement. SQL Server requires the cursor option to return the affected rows.

This commit is contained in:
Juan Basso 2011-05-21 22:40:30 -04:00
parent 11d249e43b
commit 968fa1d5ef
2 changed files with 18 additions and 2 deletions

View file

@ -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);
}
}

View file

@ -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;