thinkphp dbmysql驱动 query方法的问题

浏览:2024 发布日期:2012/12/04 分类:求助交流
做了一段时间的项目,现在有时间看TP的源码,今天看到query函数,发现有处理存储过程的,但是有段代码我不怎么清楚,求指点,代码如下:

public function query($str) {
if(0===stripos($str, 'call')){ // 存储过程查询支持
$this->close();
}
$this->initConnect(false);
if ( !$this->_linkID ) return false;
$this->queryStr = $str;
//释放前次的查询结果
if ( $this->queryID ) { $this->free(); }
N('db_query',1);
// 记录开始执行时间
G('queryStartTime');
$this->queryID = mysql_query($str, $this->_linkID);
$this->debug();
if ( false === $this->queryID ) {
$this->error();
return false;
} else {
$this->numRows = mysql_num_rows($this->queryID);
return $this->getAll();
}
}


我不明白的是,为什么 判断是存储过程之后,要关闭数据库,然后再重新连接数据库
最佳答案
评论( 相关
后面还有条评论,点击查看>>