你好 stackoverflow 人 :) 我想从 2 个表中获取数据。我不想要任何特定的“位置”选项,所以这是我的模型代码:
$this->db->from('table1, table2');
$this->db->order_by('table1.date, table2.date', "desc");
$query = $this->db->get('', $num, $offset);
return $query->result_array();
这样我只能从“table2”中获取信息,它只包含 1 篇文章,并且这篇文章在页面上重复了几次。这两个表具有相同的结构,我希望以这种方式编写“order_by”会有所帮助,但没有。如果我进行任何其他操作,我只能从一张表中获取信息。按日期排序很重要。希望任何人都会发现这个问题很有趣并且也会有所帮助。提前致谢!
编辑部分: 功能:
$this->db->get("table1");
$comm_numbers = $this->db->count_all_results("table1");
$config['base_url'] = base_url();
$config['total_rows'] = $comm_numbers;
$config['per_page'] = '5';
$config['uri_segment'] = 1;
$this->pagination->initialize($config);
$this->load->model("model_get_all");
$data["results"] = $this->model_get_all->getData1($config['per_page'], $this->uri->segment(1));
$this->load->helper('url');