我正在使用mysql作为我的数据库。我从模型中调用了一个存储过程。以下是我的模型功能。

public function call_sp()
    {
        $query = $this->db->query("call SPInsertEventTran()");
        return $query->result();
     }


我的存储过程如下。

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `SPInsertEventTran`(
IN IN_event_name varchar(45),
IN IN_date date,
IN IN_place varchar(45),
IN IN_starting_time time,
IN IN_end_time time,
IN IN_no_of_cams int,
IN IN_booked_or_not varchar(45),
IN IN_customer_id int,
IN IN_package_id int


)
BEGIN

iNSERT iNTO   event(event_name,date,place,starting_time,end_time,no_of_cams,booked_or_not,customer_id,package_id)
        values   (IN_Event_Name,IN_place,IN_starting_time,IN_end_time,IN_no_of_cams,IN_booked_or_not,
            IN_customer_id,IN_package_id);

insert into quotation (camera_charges,other,discount,event_id)
    select ev.no_of_cams*pg.charge_per_cam ,null,null,ev.id
     from event ev
    inner join package pg on ev.package_id=pg.id
    where ev.id=(select max(id) from event);
END


我收到这样的错误。

Error Number: 1318
Incorrect number of arguments for PROCEDURE mydb.SPInsertEventTran; expected 9, got 0
call SPInsertEventTran()
Filename: F:\wamp\www\eventmanagementsystem\system\database\DB_driver.php
Line Number: 331


谁能帮我解决错误?

最佳答案

您必须在CALL方法中传递所有参数,如下所示:

$sql = "CALL call SPInsertEventTran(?,?,?,?,?,?,?,?,?)";

$this->db->query($sql,[
    'Event_Name'    => 'value',
    'place'         => 'value'
    'starting_time' => 'value'
    'end_time'      => 'value'
    'no_of_cams'    => 'value'
    'booked_or_not' => 'value'
    'customer_id'   => 'value'
    'package_id'    => 'value'
]);

关于mysql - 从Codeigniter调用存储过程不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40590663/

10-10 12:31
查看更多