Welcome Guest, Not a member yet? Register   Sign In
Multiply data return model->controller
#1

[eluser]dimaomni[/eluser]
Hi,

How to correct return multiply data from Model ($data['getid']), to get possibility access data the same as $data['query'] . Like:

View:
Code:
foreach ($getid as $a){
$a->customer_id;
} echo $a;
------------------------------------


Controller:
Code:
$data['query'] = $this->Mcustomer->view_customer();
$data['getid'] = $this->Mcustomer->get_id();
$this->load->view('admin/wcustomer',$data);


Model:
Code:
function get_id(){
        $getid1 = $this->db->query("SELECT MAX(`customer_id`)FROM `customer`");
        $getid2 = $this->db->query("SELECT MAX(`branch_id`)FROM `branch`");
        $getid3 = $this->db->query("SELECT MAX(`equipment_id`)FROM `equipment`");
        $getid4 = $this->db->query("SELECT MAX(`contact_id`)FROM `contact`");
        return array('customer_id'=>$getid1, 'branch_id'=>$getid2,'equipment_id'=>$getid3,'contact_id'=>$getid4);
#2

[eluser]dimaomni[/eluser]
Resolved by creating own function for each query like:
Code:
$this->load->model('admin/Mcustomer');
    $data['query']            = $this->Mcustomer->view_customer();
   $data['get_id_customer']  = $this->Mcustomer->get_customer_id();
   $data['get_id_branch']    = $this->Mcustomer->get_branch_id();
   $data['get_id_equipment'] = $this->Mcustomer->get_equipment_id();
   $data['get_id_contact']   = $this->Mcustomer->get_contact_id();
          $this->load->view('admin/wcustomer',$data);




Theme © iAndrew 2016 - Forum software by © MyBB