Merge pull request #3301 from ubermaniac/Sqlserver-trim

Trim $sql before checking for SELECT
This commit is contained in:
Mark Story 2014-04-11 18:48:41 -04:00
commit d2fa1b444f

View file

@ -760,6 +760,7 @@ class Sqlserver extends DboSource {
*/ */
protected function _execute($sql, $params = array(), $prepareOptions = array()) { protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$this->_lastAffected = false; $this->_lastAffected = false;
$sql = trim($sql);
if (strncasecmp($sql, 'SELECT', 6) === 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) { if (strncasecmp($sql, 'SELECT', 6) === 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) {
$prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL); $prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL);
return parent::_execute($sql, $params, $prepareOptions); return parent::_execute($sql, $params, $prepareOptions);