php - run multiple select quires in one page using codeigniter -
hello 1 can tell how load 2 function model class in controller 1 method. want run multiple select quires in 1 page using codeigniter:
controller
public function property_detail( $id ) {     $this->load->model('insertmodel');      $select1 = $this->insertmodel->find($id);     $select2 = $this->insertmodel->detail_list();      $data = array();      $this->load->view('home/property_detail', ['select1'=>$select1], ['select2'=>$select2]);     //$this->load->view('home/property_detail', ['select2'=>$select2]);  } model
public function find( $id ) {     $query = $this->db->from('article')->where(['id'=> $id])->get();     if( $query->num_rows() )         return $query->row();     return false; }  public function detail_list(){      $query1 = $this->db->query("select * article");     return $query1->result(); } 
in controller
public function property_detail( $id ) {     $this->load->model('insertmodel');      $data['select1'] = $this->insertmodel->find($id);     $data['select2'] = $this->insertmodel->detail_list();      $this->load->view('home/property_detail', $data); } in model
public function find($id) {     $query = $this->db->get_where('article', array('id' => $id), 0, 0)->get();     if( $query->num_rows() > 0 )     {         $result =  $query->result_array();         return $result;     }     else     {         return false;     }     }  public function detail_list() {     $query1 = $this->db->query("select * article");     $result =  $query1->result_array();     return $result; } in view
foreach ($select2 $item) {     # foreach lop goes here } as check
empty()before passing foreach loop
Comments
Post a Comment