le_el 发表于 2008-8-9 11:31:22

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

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;?>   //取不到值,??????????????为何?

Hex 发表于 2008-8-9 17:26:45

$rs->result(); 返回的是对象数组,而不是一个对象。
你需要在视图里用 foreach 来显示。

le_el 发表于 2008-8-9 17:44:30

发错贴了,居然没得删???
页: [1]
查看完整版本: $this->db->join()的使用,问题在哪里?