Hopefully a very easy question for you. I have a PHP object, one of the properties has brackets in it (from using MIN mysql command):
stdClass Object ( [uid] => 5 [min(time)] => 13.40 )
how can I call this property? I have tried all sorts but nothing seems to work, and cannot seem to find any info on the interwebs.
Thanks very muchly!
To directly answer your question, use curly braces around the property name as a string:
$row->{'min(time)'}
A better idea, though, is to give your aggregate value an alias in your SQL as mentioned by the other answers, then access the property by that alias. Defining an alias also gives you an opportunity to supply a more meaningful name than just a call to some aggregate function on a certain column or value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With