php - how to retrieve 2 specific rows from db in laravel -
i'm new laravel. have searched laravel doc site question. in 1 of laravel view page need display value of 2 rows
1) mtitle 2) mdescription
the table contains more rows. columns name,value,key,status
. wrote query builder in blade.php using model file this.
$default = specific::where('status',1)->where('name','mtitle')->first();
this gets 1 row. want know there way other row 'mdescription' without writing 1 more query?
assuming want rows have name column set mtitle
or description
, utilize wherein
method way:
$default = specific::where('status',1) ->wherein('name',['mtitle','description'])->get();
you can display value of rows using loop:
foreach ($default $item) { echo $item->name.' '.$item->value.' '.$item->key.' '.$item->status; }
php laravel-4 query-builder
No comments:
Post a Comment