CI下优化sqlserver数据库连接

最近ci连接sqlserver一直很慢,所以考虑怎么优化一下

因为使用的了php_sqlsrv.dll 所以主要考虑这个驱动器文件的修改
(system/database/drivers/sqlsrv/sqlsrv_driver)

sqlsrv_connect 的连接里增加参数 MultipleActiveResultSets"=>'0'

$connection = array(
            'UID'               => empty($this->username) ? '' : $this->username,
            'PWD'               => empty($this->password) ? '' : $this->password,
            'Database'          => $this->database,
            'ConnectionPooling' => $pooling ? 1 : 0,
            'CharacterSet'      => $character_set,
            'ReturnDatesAsStrings' => 1,
            'MultipleActiveResultSets' => 0
        );

如果服务器配置不错的也可以将

'Scrollable' => SQLSRV_CURSOR_STATIC,

修改为
'Scrollable' => SQLSRV_CURSOR_CLIENT_BUFFERED

你可能感兴趣的:(CI下优化sqlserver数据库连接)