CodeIgniter Forums
Stored Procedure not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Stored Procedure not working (/showthread.php?tid=70465)



Stored Procedure not working - viralprajapati - 04-13-2018

I have issue in call stored procedure with null value in Codeigniter 3.
I'm trying this in Model

Code:
$foo_sql = $this->db->query('call getFooData(' . $foo_id . ', "' . $fooname . '")');
$result_arr = $foo_sql->result_array();

Also I tried with
Quote:call getFooData(2152, NULL)

Code:
DELIMITER $$
CREATE DEFINER=`foodb`@`localhost` PROCEDURE `getFooData`(IN `foo_id` INT, IN `foo_name` VARCHAR(255))
BEGIN
IF foo_id!='' and foo_name!='' THEN
  SELECT
       *
   FROM
       `tblFoodata`
   WHERE `vFooName` =  foo_name AND `sc`.`iFooId` = foo_id

END IF;
END$$
DELIMITER ;

some time $fooname is null at that time CI3 return below error
Quote:Call to a member function fetch_assoc() on boolean


Please help me how to fix it.


RE: Stored Procedure not working - InsiteFX - 04-13-2018

Try it like this and see if it works, not tested.

PHP Code:
$foo_sql $this->db->query("call getFooData('{$foo_id}', '{$fooname}');"); 
For one you are missing the procedure semi-colon.


RE: Stored Procedure not working - viralprajapati - 04-20-2018

Hi InsiteFX,

Thanks for your reply. Your code is not working.


RE: Stored Procedure not working - InsiteFX - 04-20-2018

Did some more researching on this and found this article on it.

Stored procedure in codeigniter

Hope that helps,


RE: Stored Procedure not working - viralprajapati - 04-23-2018

I have tried this Url but did not get solution. I think we need send this to CI's Developer.


RE: Stored Procedure not working - InsiteFX - 04-23-2018

I know in the older versions that they had to hack the core database and add a mysql_fetch_next method.

But I do not believe in hacking the core!