本文介紹了如何在 CodeIgniter 中調用存儲過程?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我無法在 CodeIgniter 中調用存儲過程.但是,當我直接在 MySQL 中調用該過程時,它可以工作.為什么我在 CodeIgniter 中調用它時它不起作用?
I can't call a stored procedure in CodeIgniter. However, when I call the procedure directly in MySQL, it works. Why isn't it working when I call it in CodeIgniter?
CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc`()
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
declare name1 TEXT;
declare id1 TEXT;
select name,id into name1,id1 from my_tbl WHERE name='sam';
select * from my_tbl;
select name1,id1;
END
推薦答案
我覺得你是用下面的方式來調用過程.
I think you are using the following way to call procedure.
$this->db->call_function('test_proc');
錯了.使用此方法只能調用默認過程.要調用您定義的過程,您必須使用
Its wrong. Only default procedures can be called using this method. To call procedures defined by you, you have to go with
$this->db->query("call test_proc()");
這篇關于如何在 CodeIgniter 中調用存儲過程?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!