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];