dimanche 26 juin 2016

Iterate over an array's elements to perfrom queries using Laravel Eloquent advanced WHERE clauses

I have an array (arr) with n elements, n = 1 or 2, and a table in database called employees that contains two fields (name and surname)

I want to perform the following query using Eloquent (and, possibly, some kind of iteration ?), in order to implement an "instant search" functionality:

select * from employees
where (name LIKE '%arr[0]%' AND surname LIKE '%arr[1]%')
OR
where (name LIKE '%arr[1]%' AND surname LIKE '%arr[0]%')

Any help appreciated

Thank you



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/28WjUpo
via IFTTT

Aucun commentaire:

Enregistrer un commentaire