tp5 聊天記錄多條件whereor查詢

1.首先定義所需要的查詢條件

$data1 = "fromid=". $fromid . " and " . "toid=" . $toid;
$data2 = "fromid=" . $toid . " and " . "toid=" . $fromid;

2.使用Db類執行查詢 如:

$count = Db::name('communication')->where($data1)->whereor($data2)->field('content')->order('id')->count();
			
if($count>10){
	  $list = Db::name('communication')->where($data1)->whereor($data2)->limit($count-10,10)->order('id')->select();
}else{
	  $list = Db::name('communication')->where($data1)->whereor($data2)->field('content')->order('id')->select();
}

return ['count'=>$count,'list'=>$list];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章