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).
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 09e6b8c..2759bac 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -48,6 +48,18 @@
 	 */
 	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 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 @@
 	 */
 	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));
 	}
 
 	// --------------------------------------------------------------------