zoukankan      html  css  js  c++  java
  • ThinkPHP 2053错误

    这个报错是调用存储过程的时候产生的,用的是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
    

      

    原因:

    在  hinkphplibrary hinkdbConnection.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;
        }
    

      

  • 相关阅读:
    杂记:高僧的炒股境界
    在Windows 7中使用tsmmc远程桌面
    VS2010初体验
    code4fun: one service,one config
    WCF进阶:将编码后的字节流压缩传输
    有高手想换工作的么?
    code4fun:host wcf service just in time
    evey的几张鼠绘
    说说WCF Rest
    外包一类似联众room的项目
  • 原文地址:https://www.cnblogs.com/pangxiaox/p/9562613.html
Copyright © 2011-2022 走看看