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 301<br />

In the above example, we would like to retrieve all rows with a title field that starts with three<br />

period characters .... The percentage % sign will let the database know that we don’t care what<br />

value comes after our triple period. As a side note, I know that a triple period is known as an ellipsis,<br />

I just thought this might be easier for readers who don’t have English as a first language.<br />

Let’s take a look at the result from the / URI.<br />

1 [<br />

2 {<br />

3 id: 5,<br />

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

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

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

7 year: 1997<br />

8 },<br />

9 {<br />

10 id: 6,<br />

11 title: "...Is A Real Boy",<br />

12 artist: "Say Anything",<br />

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

14 year: 2006<br />

15 }<br />

16 ]<br />

We receive a result collection for the albums titled ‘…Anywhere But Here’ and ‘…Is A Real Boy’,<br />

both of which start with a triple period, and are fabulous albums.<br />

We aren’t limited to a single where() method call within a query. We can chain multiple where()<br />

methods together to retrieve rows based on a number of different criteria. Here’s an example.<br />

1

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

Saved successfully!

Ooh no, something went wrong!