CodeIgniter Forums
Two procedures continuesly 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: Two procedures continuesly not working (/showthread.php?tid=67716)



Two procedures continuesly not working - Vijay Verma - 03-31-2017

If I'm executing only 1 procedure in the model - all works fine, but 2 returns nothing. If I use simple query(not procedure) in first part, all is working fine

For example:

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
   class Newroom_model extends CI_Model {

       function __construct()
       {
           parent::__construct();
       }

       function get()
       {
           $data=array();

           //First
           $query=$this->db->query("call GetHomeTypes()");
           $res = $query->result_array();
           for($i=0;$i<count($res);$i++)
           {
               $data['home_Types'][$i]['Type_ID']=$res[$i]['TypeID'];
               $data['home_Types'][$i]['Type_Name']=$res[$i]['TypeName'];
           }
           //Second
           $query2=$this->db->query("call GetRoomTypes()");
           $res1 = $query2->result_array();
           for($i=0;$i<count($res1);$i++)
           {
               $data['room_Types'][$i]['Type_ID']=$res1[$i]['TypeID'];
               $data['room_Types'][$i]['Type_Name']=$res1[$i]['TypeName'];
           }

           // print_r($data);
           return $data;
       }
   }
?>



RE: Two procedures continuesly not working - InsiteFX - 03-31-2017

Try adding this:

PHP Code:
$query->free_result();

//Second 


This usually happens because the first query has not finished running.