I need to get all rows of the table. Currently I do that like this:
$all_rows = TBname::where('id', '>', '0')->get();
As you see, I've used id > 0
condition to select all rows. But I think this isn't a standard way. In pure SQL I can use . . . where 1
. . . where 1
. . . where 1
. But in Laravel where('1')
doesn't work.
Anyway, what's the most standard approach to select (and fetch) all rows in Laravel?
Use all()
:
TBname::all();
Or get()
:
TBname::get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.