这个报错是调用存储过程的时候产生的,用的是5.1的代码是根据官方文档写的,我怀疑5.0也有这个问题。去官方查了一下发现不少人有这个问题,但是官方都没有回应过,只能自己动手一步步调了。
$center = input(‘c‘,1);
$outParam = null;
$data = Db::query(‘call get_day(:in_param2)‘,[
???‘in_param2‘ => [&$center, \PDO::PARAM_INT],
]);
注意这里的变量要用引用的方式
TP5.1 报错 SQLSTATE[HY000]: General error: 2053
原因:
在 \thinkphp\library\think\db\Connection.php 里面有这么一个获取存储过程结果的函数
/** ????* 获得存储过程数据集 ????* @access protected ????* @return array ????*/ ???protected function procedure() ???{ ???????$item = []; ???????do { ???????????$result = $this->getResult(); ???????????if ($result) { ???????????????$item[] = $result; ???????????} ???????} while ($this->PDOStatement->nextRowset()); ???????$this->numRows = count($item); ???????return $item; ???}
我打印出来
$this->getResult();
返回的结果集就是一个,但是这里又判断循环是否下一行,我怀疑就是这里出错了。把这里获取结果集直接返回就可以了
/** ????* 获得存储过程数据集 ????* @access protected ????* @return array ????*/ ???protected function procedure() ???{ ???????$result = $this->getResult(); ???????$this->numRows = count($result); ???????return $result; ???}
ThinkPHP 2053错误
原文地址:https://www.cnblogs.com/pangxiaox/p/9562613.html