summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/sqlsrv/sqlsrv_result.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-21 18:04:18 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-21 18:04:18 +0100
commitba8bf563095657b8b6104ecc3d3a990f3e6ceb75 (patch)
tree3ccefa6d94206ba51d6afa1a0c2be103ca81a612 /system/database/drivers/sqlsrv/sqlsrv_result.php
parent4d0571666d03511ac5b4a1f2a6882ccb1509a209 (diff)
SQLSRV improvements
Mainly for performance (issue #2474), but also added a 'scrollable' configuration flag and auto-detection for SQLSRV_CURSOR_CLIENT_BUFFERED (only available since SQLSRV 3).
Diffstat (limited to 'system/database/drivers/sqlsrv/sqlsrv_result.php')
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_result.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 3c8148f1b..ba38f7454 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -39,15 +39,45 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class CI_DB_sqlsrv_result extends CI_DB_result {
/**
+ * Scrollable flag
+ *
+ * @var mixed
+ */
+ public $scrollable;
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Constructor
+ *
+ * @param object $driver_object
+ * @return void
+ */
+ public function __construct(&$driver_object)
+ {
+ parent::__construct($driver_object);
+
+ $this->scrollable = $driver_object->scrollable;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Number of rows in the result set
*
* @return int
*/
public function num_rows()
{
+ // sqlsrv_num_rows() doesn't work with the FORWARD and DYNAMIC cursors (FALSE is the same as FORWARD)
+ if ( ! in_array($this->scrollable, array(FALSE, SQLSRV_CURSOR_FORWARD, SQLSRV_CURSOR_DYNAMIC), TRUE))
+ {
+ return parent::num_rows();
+ }
+
return is_int($this->num_rows)
? $this->num_rows
- : $this->num_rows = @sqlsrv_num_rows($this->result_id);
+ : $this->num_rows = sqlsrv_num_rows($this->result_id);
}
// --------------------------------------------------------------------