我正在使用mysql作为我的数据库。我从我的模型中调用了一个存储过程。以下是我的模特函数。
AudioManager
我的存储过程如下。
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
有人可以帮我解决错误吗?
答案 0 :(得分:1)
您必须传递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'
]);