06.10.2016 Views

laravel-5

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

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

Database: Query Builder 527<br />

1 $users = DB::table('users')->where([<br />

2 ['status','1'],<br />

3 ['subscribed','','1'],<br />

4 ])->get();<br />

Or Statements<br />

You may chain where constraints together, as well as add or clauses to the query. The orWhere<br />

method accepts the same arguments as the where method:<br />

1 $users = DB::table('users')<br />

2 ->where('votes', '>', 100)<br />

3 ->orWhere('name', 'John')<br />

4 ->get();<br />

Additional Where Clauses<br />

whereBetween<br />

The whereBetween method verifies that a column’s value is between two values:<br />

1 $users = DB::table('users')<br />

2 ->whereBetween('votes', [1, 100])->get();<br />

whereNotBetween<br />

The whereNotBetween method verifies that a column’s value lies outside of two values:<br />

1 $users = DB::table('users')<br />

2 ->whereNotBetween('votes', [1, 100])<br />

3 ->get();<br />

whereIn / whereNotIn<br />

The whereIn method verifies that a given column’s value is contained within the given array:

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

Saved successfully!

Ooh no, something went wrong!