gpt4 book ai didi

php - Laravel-5.6 'LIKE' 在选择的地方

转载 作者:行者123 更新时间:2023-12-01 00:35:05 24 4
gpt4 key购买 nike

我使用此查询时出现错误:

 $description = $request->get('description');
if (!empty($description)){
$description_query = Transcationhistorique::where(['sender_id' => $user_id, "%$description%", 'LIKE','description'])
->orWhere('receiver_id', $user_id)->get();
}else{
$description_query = "" ;
}

这是我得到的错误:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' (SQL: select * from transcation_historique where (sender_id = 32 and 0 = %salaire% and 1 = LIKE and 2 = description) or receiver_id = 32)"

这就是我真正想要运行的:

select * from `transcation_historique` where (`sender_id` = 32 and `description` = %salaire%) or `receiver_id` = 32)

最佳答案

试试这个,

$description_query = Transcationhistorique::where(
function($query) use ($user_id, $description){
return $query->where('sender_id', $user_id)
->where('description', 'like', '%' . $description .'%');

}
)
->orWhere('receiver_id', $user_id)
->get();

关于php - Laravel-5.6 'LIKE' 在选择的地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54883894/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com