1

I have an array with an object. The value of the object is a counter from my database. I need to make a condition on that object.

var_dump($myArray);

return

array (size=1)
0 => 
object(stdClass)[62]
  public 'count(videos_like.videos_like_id)' => string '5' (length=1)

I try to do it like so:

if($myArray[0]->count(videos_like.videos_like_id) == '5'){...}

But of course I get an error. Does anyone have an idea?

1 Answer 1

3

I'd rather advise you to update your SQL query and replace code:

count(videos_like.videos_like_id)

to

count(videos_like.videos_like_id) AS videosCount

hence you won't have this problem.

PS: Even you don't have plain SQL and use any framework - it's definitely possible to provide alias to your count column.

Sign up to request clarification or add additional context in comments.

Comments

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.