11.08.2017 Views

codebright

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Eloquent Queries 309<br />

1 select * from `albums` where `artist` in (?, ?)<br />

Here’s the collection of results that we receive from the example query.<br />

1 [<br />

2 {<br />

3 id: 3,<br />

4 title: "Leaving Through The Window",<br />

5 artist: "Something Corporate",<br />

6 genre: "Piano Rock",<br />

7 year: 2002<br />

8 },<br />

9 {<br />

10 id: 4,<br />

11 title: "North",<br />

12 artist: "Something Corporate",<br />

13 genre: "Piano Rock",<br />

14 year: 2002<br />

15 },<br />

16 {<br />

17 id: 5,<br />

18 title: "...Anywhere But Here",<br />

19 artist: "The Ataris",<br />

20 genre: "Punk Rock",<br />

21 year: 1997<br />

22 }<br />

23 ]<br />

The whereIn() method also has the usual method alternative in the form of orWhereIn() and can<br />

be chained multiple times.<br />

WhereNotIn<br />

The whereNotIn() method is the direct opposite to the whereIn() method. This time you provide a<br />

list of values, and the column value must not exist within the set.<br />

Let’s take a look at an example.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!