thinkPHP3.2中join與field,order,where的配合使用
//要接廣告
$readhehe=M('public_adv');
$mycontent=M("mytext");
$ccc=$readhehe->join('tp_mytext ON tp_public_adv.choose_text_id = tp_mytext.id')
->where('tp_public_adv.wp_public_status=1 and tp_public_adv.public_status=2')
->order('tp_public_adv.id desc')->select();
$count = $readhehe->join('tp_mytext ON tp_public_adv.choose_text_id = tp_mytext.id')
->where('tp_public_adv.wp_public_status=1 and tp_public_adv.public_status=2')->count();
$p = getpage($count,4);
$p->rollPage=6;
$list = $readhehe->table("tp_public_adv as u")
->join("tp_mytext as b ON b.id=u.choose_text_id")
->field('b.*,b.id as tid,u.*')
->where('u.wp_public_status=1 and u.public_status=2')
->order('u.id desc')->limit($p->firstRow, $p->listRows)->select();
$this->assign("page", $p->show());// 賦值分頁輸出
$this->assign('ccc',$list);// 賦值資料集
$this->view();
}