Welcome Guest, Not a member yet? Register   Sign In
Stored Procedure not working
#1

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.
Reply
#2

(This post was last modified: 04-13-2018, 04:09 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Hi InsiteFX,

Thanks for your reply. Your code is not working.
Reply
#4

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

Stored procedure in codeigniter

Hope that helps,
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

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

(This post was last modified: 04-23-2018, 04:26 AM by InsiteFX.)

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!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB