Ahm*_*smi 0 php mysql laravel laravel-5 laravel-5.6
我使用此查询,我收到一个错误:
$description = $request->get('description');
$description_query = Transcationhistorique::where(function ($query) use ($description, $user_id) {
$query->where('receiver_id', $user_id,'description', 'LIKE','%' . $description . '%')
->orWhere('description', 'LIKE','%' . $description . '%','sender_id', $user_id);
})->get();
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
"SQLSTATE [42S22]:未找到列:1054'where 子句'中的未知列'0'(SQL:select*from
transcation_historiquewhere(sender_id= 32 and0=%salaire%and1= LIKE and2= description)orreceiver_id= 32)"
这就是我真正想要的:
select * from `transcation_historique` where (`sender_id` = 32 and `description` = %salaire%) or (`receiver_id` = 32 and `description` = %salaire%)
Run Code Online (Sandbox Code Playgroud)
小智 5
试试这个
Transcationhistorique::where(function ($query) use ($description, $user_id) {
$query->where(['receiver_id' => $user_id, 'description' => 'LIKE %' . $description . '%'])
->orWhere(['description' => 'LIKE %' . $description . '%', 'sender_id' => $user_id]);
})->get();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |