I am using Laravel with a select statement to select the row with the highest id like this:
$user_id = DB::connection('mysql2')->select('SELECT MAX(id) FROM users')[0];
This returns an array with an object that looks like this:
stdClass Object ( [MAX(id)] => 11 ) 1
I have tried $object->MAX(id) and $object['MAX(id)'] but it does not seem to work.
Dynamic attributes with usually not allowed characters can be accessed using curly brackets like this:
$object->{"MAX(id)"}
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