CodeIgniter2.0中sqlserver驱动返回受影响行数问题解决
最近使用CI写项目时遇到的问题,当使用sqlserve链接操作时 修改和删除返回的受影响行数不对
解决办法如下:
找到ci框架目录中include\database\drivers\sqlsrv\sqlsrv_driver.php
sqlsrv_drive()方法 修改和删除数据返回受影响行数
原始:
function _execute($sql) { $sql = $this->_prep_query($sql); return sqlsrv_query($this->conn_id, $sql, null, array(Scrollable' => SQLSRV_CURSOR_STATIC,'SendStreamParamsAtExec'=> true)); }
修改为:
function _execute($sql) { $sql = $this->_prep_query($sql); if(stripos($sql,'UPDATE') !== FALSE || stripos($sql,'INSERT') !== FALSE) { return sqlsrv_query($this->conn_id, $sql, null, array()); } return sqlsrv_query($this->conn_id, $sql, null, array('Scrollable' => SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => true)); }
朝朝暮暮.