用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4232|回复: 2
收起左侧

$this->db->join()的使用,问题在哪里?

[复制链接]
发表于 2008-8-9 11:31:22 | 显示全部楼层 |阅读模式
models: getdataM

function getdateCondition($per_page,$start,$cond){
  $this->db->select("A.*,B.typename");
  $this->db->from("A");
  $this->db->join('B','B.f_id=B.typeid');                                              //  $this->db->join的使用。
  $this->db->where($cond);
  $this->db->orderby('createtime','desc');
  $this->db->limit($per_page,$start);
  $rs=$this->db->get();
  $res=$rs->result();
  return $res;
}

controls:

function index($start=0){
  $conf['per_page']=50;
  $conf['total_rows']=$this->getdataM->totalRecordsByCondition("where status='1'");
  $conf['base_url']=site_url()."/index/";
  $conf['uri_segment']=3;
  $this->load->library('pagination',$conf);
  $temp['links']=$this->pagination->create_links();
  $res=$this->getdataM->getdataCondition($conf['per_page'],$start,array('status'=>'1'));
  $temp['res']=$res;
  $temp['per_page']=$conf['per_page'];
  $this->load->view('indexview',$temp);  
}

views:

<?=$res->f_typename;?>   //取不到值,??????????????为何?
发表于 2008-8-9 17:26:45 | 显示全部楼层
$rs->result(); 返回的是对象数组,而不是一个对象。
你需要在视图里用 foreach 来显示。
 楼主| 发表于 2008-8-9 17:44:30 | 显示全部楼层
发错贴了,居然没得删???

本版积分规则