北极宫爵 发表于 2009-5-19 17:47:35

请问CI如何多表查询

如: select n.title,n.postdate from news as n,form menu as m where m.menuid=n.newsid

在用CI下如何写
谢谢~`

caincheung 发表于 2009-5-20 04:32:39

$this->db->join
详细看手册

sam 发表于 2009-5-20 09:44:18

默认,CI可以使用普通sql语句,没必要非得用ar

shinelake 发表于 2009-5-20 15:08:01

刚好我这有一个例子:

shinelake 发表于 2009-5-20 15:10:33

$this->db->select('a.long_id,a.name,a.description,a.configuration,'
      .' b.name as catetory,c.name as period,d.name as status,'
      .' e.name as type,a.startdate,a.enddate');
      $this->db->from('u_projects as a');
      $this->db->join('d_project_category as b', 'a.category_id = b.id');
      $this->db->join('d_project_period as c', 'a.period_id = c.id');
      $this->db->join('d_project_status as d', 'a.status_id = d.id');
      $this->db->join('d_project_type as e', 'a.type_id = e.id');
      $this->db->order_by('a.name');
      $this->db->limit($num);
      return $this->db->get();

kinch 发表于 2009-5-20 15:38:03

还是自己写语句吧。
页: [1]
查看完整版本: 请问CI如何多表查询