I am using Cassandra and using the Datastax PHP CQL.
Given the following query, how should I decode the result?
$cql = SELECT * FROM company WHERE userid = 1001 ORDER BY gpsTime DESC LIMIT 1;
$statement = new Cassandra\SimpleStatement($cql);
$result = $this->session->execute($statement);
I tried decoding with:
foreach($result as $row){
// Get values from row and add to array
array_push($allVehicleInfo,array(
'userID' => $row['userid']->value,
'gpsTime' => $row['gpstime']->seconds,
'latitude' => $row['latitude']->value )
);
}
However, I get an error:
Message: Undefined property: Cassandra\Decimal::$value
My table schema is:
$cql = "CREATE TABLE " company " (
userID bigint,
userName ascii,
latitude decimal,
longitude decimal,
accuracy float,
altitude float,
gpsTime timestamp );
value
is a function and not property, so you'll have to do $row['latitude']->value()