Skip to content

Commit b9ce614

Browse files
committed
sqlsrv驱动改进对参数绑定的支持
1 parent d328832 commit b9ce614

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Extend/Driver/Db/DbSqlsrv.class.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ public function free() {
7171
public function query($str,$bind=array()) {
7272
$this->initConnect(false);
7373
if ( !$this->_linkID ) return false;
74-
$this->queryStr = $str;
7574
//释放前次的查询结果
7675
if ( $this->queryID ) $this->free();
7776
N('db_query',1);
7877
// 记录开始执行时间
7978
G('queryStartTime');
79+
$str = str_replace(array_keys($bind),'?',$str);
80+
$bind = array_values($bind);
81+
$this->queryStr = $str;
8082
$this->queryID = sqlsrv_query($this->_linkID,$str,$bind, array( "Scrollable" => SQLSRV_CURSOR_KEYSET));
8183
$this->debug();
8284
if ( false === $this->queryID ) {
@@ -98,12 +100,14 @@ public function query($str,$bind=array()) {
98100
public function execute($str,$bind=array()) {
99101
$this->initConnect(true);
100102
if ( !$this->_linkID ) return false;
101-
$this->queryStr = $str;
102103
//释放前次的查询结果
103104
if ( $this->queryID ) $this->free();
104105
N('db_write',1);
105106
// 记录开始执行时间
106107
G('queryStartTime');
108+
$str = str_replace(array_keys($bind),'?',$str);
109+
$bind = array_values($bind);
110+
$this->queryStr = $str;
107111
$this->queryID= sqlsrv_query($this->_linkID,$str,$bind);
108112
$this->debug();
109113
if ( false === $this->queryID ) {

0 commit comments

Comments
 (0)