diff options
author | Andrey Andreev <narf@devilix.net> | 2014-01-24 13:28:47 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-01-24 13:28:47 +0100 |
commit | 98d6cc84718f471b150bb4e1ec93a7c89a967f69 (patch) | |
tree | bf7bc5507eb0ea6f9372d7d15c88069d32798f40 /system/database/drivers/sqlsrv/sqlsrv_driver.php | |
parent | de1fe7d504898bc6a42e24b4c73da3887a9933d6 (diff) | |
parent | ecc260e0be0cdb55c4e4802b78ddd78b0d8b0ebc (diff) |
Merge branch 'develop' into feature/user-guide-cleanup
Diffstat (limited to 'system/database/drivers/sqlsrv/sqlsrv_driver.php')
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_driver.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 09e6b8c9a..2759bac0b 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -48,6 +48,18 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ public $dbdriver = 'sqlsrv'; + /** + * Scrollable flag + * + * Determines what cursor type to use when executing queries. + * + * FALSE or SQLSRV_CURSOR_FORWARD would increase performance, + * but would disable num_rows() (and possibly insert_id()) + * + * @var mixed + */ + public $scrollable; + // -------------------------------------------------------------------- /** @@ -70,6 +82,27 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- /** + * Class constructor + * + * @param array $params + * @return void + */ + public function __construct($params) + { + parent::__construct($params); + + // This is only supported as of SQLSRV 3.0 + if ($this->scrollable === NULL) + { + $this->scrollable = defined('SQLSRV_CURSOR_CLIENT_BUFFERED') + ? SQLSRV_CURSOR_CLIENT_BUFFERED + : FALSE; + } + } + + // -------------------------------------------------------------------- + + /** * Database connection * * @param bool $pooling @@ -154,9 +187,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ protected function _execute($sql) { - return ($this->is_write_type($sql) && stripos($sql, 'INSERT') === FALSE) + return ($this->scrollable === FALSE OR $this->is_write_type($sql)) ? sqlsrv_query($this->conn_id, $sql) - : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => SQLSRV_CURSOR_STATIC)); + : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => $this->scrollable)); } // -------------------------------------------------------------------- |