Using Laravel 5.4 I am trying to run this query that gets me results on phpMyAdmin:
select * from `orders`
inner join `users` on `user_id` = `users`.`id`
where `status` = ?
and (`orders`.`id` LIKE ? or `first_name` LIKE ? or `last_name` LIKE ? or `company` LIKE ?
The problem is, although I get results in phpMyAdmin I get an empty result in the code.
I tried two ways:
$orders = Order::join('users', 'user_id', '=', 'users.id')
->whereRaw("status = ? and (orders.id LIKE '%?%' or first_name LIKE '%?%' or last_name LIKE '%?%' or company LIKE '%?%')",
[$status, $search, $search, $search, $search])->get();
And
$orders = Order::join('users', 'user_id', '=', 'users.id')
->whereRaw("status = :status and
(orders.id LIKE :search_id or first_name LIKE :search_first or last_name LIKE :search_last or company LIKE :search_company)",
['status'=>$status, 'search_id'=>$search, 'search_first'=>$search, 'search_last'=>$search, 'search_company'=>$search])
->get();
What am I doing wrong?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2EZSxOK
via IFTTT
Aucun commentaire:
Enregistrer un commentaire