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];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章