From afa64cfd21a77d232222fb6a9c57ee790f1ab4ca Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 25 May 2016 19:20:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=AD=98=E5=82=A8=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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