【发布时间】:2018-04-04 04:15:48
【问题描述】:
我有一种情况要从数据库中过滤用户,方法是从具有特定 id 的表的两列中过滤,并且应该使用日期范围进行过滤。
我的代码如下所示。
$fetchSelectedUser=Wallet_Transaction::select('wallet__transactions.from as FromUser','wallet__transactions.type','wallet__transactions.date','wallet__transactions.amount','wallet__transactions.balance_after',
'wallet__transactions.type','wallet__transactions.description','wallet__transactions.to as ToUser','users.name as FromName',DB::raw('(select name from users where users.id = ToUser) as toName'))
->join('users','users.id','=','wallet__transactions.from')
->where('wallet__transactions.from','=',$user_id)->orWhere('wallet__transactions.to','=',$user_id)
->whereBetween('wallet__transactions.db_date',[$fromDate,$toDate])->get();
我尝试过的是放置一个静态日期,但不起作用。我还分别删除了orWhere 和whereBetween。那是有效的。但它不会一起工作。
【问题讨论】:
-
你能解释一下你想在这里实现什么,你的查询用一些例子吗?
标签: php database laravel laravel-5.4