YACassandraPDO : How to fetch UUID column from cassandra table

It is observer that when we fetch the UUID field using YACassandraPDO driver in PHP it fetches the garbage. for example

select dateof(uuidfield) as theTimeStamp from table;

output will be :

array(1) {
[0]=>
array(2) {
["theTimeStamp"]=>
string(8) "�;e$��"
[0]=>
string(8) "�;e$��"
}
}

Expected:

array(1) {
[0]=>
array(2) {
["theTimeStamp"]=>
string(8) "2012-12-04 10:00:00+0100"
[0]=>
string(8) "2012-12-04 10:00:00+0100"
}
}

For timestamp, pdo returning the hexodecimal string. You can use below function to convert it back to date string.


function getDateStringFromHex($str) {
$date = unpack('H*', $str);
$time = hexdec($date[1]) / 1000;
$dateStr = date('Y-m-d H:i:s', $time);
return $dateStr;
}

Leave a Reply