错误信息:
Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run agains
t mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
也就是说,未结束之前的查询而再次查询,这样是会出错地,所以要释放掉之前的查询。
解决方法:
$configs = $this->config;
// 解决方法就是增加这句
$configs['params'][constant('PDO::MYSQL_ATTR_USE_BUFFERED_QUERY')] = true;
if ($this->pconnect) {
$configs ['params'] [constant ( 'PDO::ATTR_PERSISTENT' )] = true;
}
try {
$this->link = new PDO ( $configs ['dsn'], $configs ['username'], $configs ['password'], $configs ['params'] );
} catch ( PDOException $e ) {
throw new exception ( $e->getMessage () );
//exit('连接失败:'.$e->getMessage());
}