Skip to content
Advertisement

how can i to convert an database object to integer in PHP (laravel)

i have a select that returns a integer value but in the variable it is stored a object that is obvious i neeed to convert to integer

$n = DB::select(‘select top 1 id form tags order by id DESC’);

then i need to convert $n to integer

Advertisement

Answer

This easy to do with ORM, if you have Tag model please try,

$n = Tag::orderBy('id','desc')->first()->id;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement