diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index e613e882..45f90eab 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -356,7 +356,8 @@ abstract class Connection $result = $this->PDOStatement->execute(); // 调试结束 $this->debug(false); - return $this->getResult($class); + $procedure = 0 === strpos(strtolower(substr(trim($sql),0,4)),'call'); + return $this->getResult($class,$procedure); } catch (\PDOException $e) { throw new PDOException($e, $this->config, $this->queryStr); } @@ -472,14 +473,18 @@ abstract class Connection * 获得数据集 * @access protected * @param bool|string $class true 返回PDOStatement 字符串用于指定返回的类名 + * @param bool $procedure 是否存储过程 * @return mixed */ - protected function getResult($class = '') + protected function getResult($class = '',$procedure=false) { if (true === $class) { // 返回PDOStatement对象处理 return $this->PDOStatement; } + if($procedure){ + return $this->procedure($class); + } $result = $this->PDOStatement->fetchAll($this->fetchType); $this->numRows = count($result); @@ -501,6 +506,23 @@ abstract class Connection return $result; } + /** + * 获得存储过程数据集 + * @access protected + * @param bool|string $class true 返回PDOStatement 字符串用于指定返回的类名 + * @return array + */ + protected function procedure($class){ + $item = []; + do { + $result = $this->getResult($class); + if($result){ + $item[] = $result; + } + } while ($this->PDOStatement->nextRowset()); + return $result; + } + /** * 执行数据库事务 * @access public