1

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

0

2 Answers 2

2

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

$n = Tag::orderBy('id','desc')->first()->id;
Sign up to request clarification or add additional context in comments.

1 Comment

Laravel retursn: ErrorException Trying to get property 'ID' of non-object
1
$n = DB::select('select top 1 id form tags order by id DESC')->first();

$id = $n->id;

your id now is $id

2 Comments

DB::select() returns an array btw
laravel returns: Symfony\Component\Debug\Exception\FatalThrowableError Call to a member function first() on array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.