Reputation: 59
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?
Upvotes: 1
Views: 37
Reputation: 17061
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.
Upvotes: 3