CodeIgniter Forums
How to execute Multiple result sets in CI ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: How to execute Multiple result sets in CI ? (/showthread.php?tid=66242)



How to execute Multiple result sets in CI ? - Abuhuraira - 09-26-2016

I have a stored procedure which returns multiple rows.

But CI is executing only single row.

How to fetch multiple result sets in CI ? 

Sample code

Code:
$query = $this->db->query('CALL proc_name(?,?)', array(19,'test'));

\**
**       should return multiple rows but returning one row only
**/

return $query->result();



RE: How to execute Multiple result sets in CI ? - zurtri - 09-26-2016

You need to cycle through the expected results with a foreach() loop as per http://www.codeigniter.com/userguide3/database/results.html

Something like this:

Code:
foreach ($query->result() as $row)
{
       echo $row->title;
       echo $row->name;
       echo $row->body;
}



RE: How to execute Multiple result sets in CI ? - Abuhuraira - 09-26-2016

Thanks for the reply.
Since I have 2 or more select queries in my stored procedure, it will still execute the first select statement results only.
The next statements are not executing.


RE: How to execute Multiple result sets in CI ? - InsiteFX - 09-27-2016

Maybe this will help


RE: How to execute Multiple result sets in CI ? - Abuhuraira - 09-28-2016

Sorry not working!


RE: How to execute Multiple result sets in CI ? - marksman - 09-28-2016

have you tried var_dump in your result? to see the data structures?


RE: How to execute Multiple result sets in CI ? - Abuhuraira - 09-28-2016

Yes, it is showing the first result set only..