TP3.2join查詢

TP3.2join查詢

$count = $this->model->table('stat_user_log')->where($map)->count(); 
$page = $this->page($count); 
$this->Page = $page->show();
      
//echo "sql:". $this->model->getLastSql(); 
      
$data=$this->model->table('stat_user_log A')//主表
                  ->join('stat_lose_user U ON A.ymd=U.ymd',"LEFT") //附表 join方式
                  ->field('A.ymd,sum(A.acc_add) as acc_add,sum(A.acc_active) as acc_active,sum(A.acc_num) as acc_num') //關鍵字段
                  ->where($map) //條件
                  ->limit($page->firstRow.",".$page->listRows) //分段
                  ->order('A.ymd desc') //排序
                  ->group("A.ymd") //分組方式
                  ->select();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章