Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
651 views
Welcome To Ask or Share your Answers For Others

1 Answer

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()");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...