Codeigniter |使用MYSQL中的IN和OUT pratameters调用存储过程

时间:2016-03-17 07:48:58

标签: mysql codeigniter call procedure

这是我的程序...它将接受$encoder的参数作为IN,然后它会将成员数输出为@current@cancelled@year它被编码为OUT。我有一个IN参数和四个OUT参数......它可以工作。

问题是如何在Codeigniter 3中执行此操作。

我已经尝试了几个代码参考codeigniter手册,但我收到了这个错误..

Error Number: 1172

Result consisted of more than one row

CALL get_members_by_status(25,@current,@current,@year1)

Filename: models/Dashboardcounts.php

Line Number: 189

这是Mysql程序代码..

BEGIN
    -- current members
     SELECT
                count(memstat) INTO current
            FROM
                members
            WHERE
                encoder = encoder_num
                    AND memstat = '1';

     -- canceled members
     SELECT
                  count(memstat) INTO cancelled
            FROM
                members
            WHERE
                encoder = encoder_num
                    AND memstat = '0';

    -- year encoded
     SELECT
                  date_format(memdateencode,"%Y") INTO year1
            FROM
                members
            WHERE
                encoder = encoder_num;
    END

这是我的标准代码......

public function linegraphchurchmemberbychurch_2(){
        $query = $this->db->query('CALL get_members_by_status(25,@current,@current,@year1)');
        $query1 = $this->db->query('SELECT @current');
        foreach ($query1->result_array() as $row){
        $data = $row;
        }
         return $data;
        }

任何提示?

0 个答案:

没有答案