mercredi 27 février 2019

Laravel-5.6 'LIKE ' in where and or where select

I use this query and i get a error :

$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();

and this is the error that I get :

"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)"

and this what really i want to run:

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire