CodeIgniter join two tables

后端 未结 2 1638
情深已故
情深已故 2021-01-16 10:24

I am trying to join two tables together using CodeIgniter. I used CodeIgniter user guide for help. I am having some issues where only one table\'s data is displayed and I d

相关标签:
2条回答
  • 2021-01-16 11:10
    function result_getall(){
    
    $this->db->select('tblanswers.*,credentials.*');
    $this->db->from('tblanswers');
    $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'left'); 
    $query = $this->db->get();
    return $query->result();
    
    }
    
    0 讨论(0)
  • 2021-01-16 11:12

    Try this in controller and see whats the result.Also,show us if you are getting any error and make sure there is data in your table :).

    Controller

    function getall(){      
        $this->load->model('result_model');
        $data['query'] =$this->result_model->result_getall();
        print_r($data['query']);
        die();
        $this->load->view('result_view', $data);
        }
    
    0 讨论(0)
提交回复
热议问题