标签 tp6 下的文章
ThinkPHP6 模型多条件关联查询
switch ($searchType) {
case 'name':
$res = OrdersModel::hasWhere('personBase',['name'=>$searchText])->paginate(100);
break;
case 'phone':
$res = OrdersModel::hasWhere('personBase',['phone'=>$searchText])->paginate(100);
break;
case 'icard':
$res = OrdersModel::hasWhere('personBase',['icard'=>$searchText])->paginate(100);
break;
case 'out_trade_no':
$res = OrdersModel::with('personBase')->where(['out_trade_no'=>$searchText])->paginate(10);
break;
case 'transaction_id':
$res = OrdersModel::with('personBase')->where(['transaction_id'=>$searchText])->paginate(10);
break;
}
think-awesome ThinkPHP5+ 资源整理
感谢ThinkPHP
官方收集整理