mercredi 4 octobre 2017

Get any of the item from the Array with whereIn in Laravel 5.3

I'm using laravel 5.3 and trying to build a query with multiple where and wherein function. Here is my code:

$posts_id = "1,3,4";  //from my query
$results = Post::select('*');   
$results->whereIn('posts_id', [$posts_id]);
$resutls->get();

There is 1 post which have an id of 4 in my database, but my query doesn't returning anything. Though there is 4 in my post ids $posts_id = "1,3,4";.

Need help, to get posts from any of the id, which I've included in my $posts_id variable.

Thanks in Advance!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire