thinkPHP3.2中join与field,order,where的配合使用

时间:2022-09-24 17:17:29
public function yjggAction(){
//要接广告
$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();
}