I'm attempting to work Cassandra 2.0 with PHP and the PDO extension. It seems to be working however I'm having trouble retrieving records.
My code is as follows
// Connect to two hosts
$dsn = "cassandra:host=localhost;port=9160,host=localhost,port=9160";
$db = new PDO($dsn);
// Select Keyspace
$db->exec("USE mykeyspace");
// Create and Excecute query
$stmt = $db->prepare("SELECT * FROM users");
$result = $stmt->execute();
// Dump to data
var_dump($stmt->fetchAll());
And this is the result of my var_dump
array(3) { [0]=> array(6) { ["user_id"]=> int(1745) [0]=> int(1745) [""]=> string(5) "smith" [1]=> string(0) "" [2]=> string(4) "john" [3]=> string(5) "smith" } [1]=> array(6) { ["user_id"]=> int(1744) [0]=> int(1744) [""]=> string(3) "doe" [1]=> string(0) "" [2]=> string(4) "john" [3]=> string(3) "doe" } [2]=> array(6) { ["user_id"]=> int(1746) [0]=> int(1746) [""]=> string(5) "smith" [1]=> string(0) "" [2]=> string(4) "john" [3]=> string(5) "smith" } }
The data is there, but it's not organized at all. Why there no fname is there which one of the names of my columns. The data is there but some of it only another numeral array keys.
The table structure is the Cassandra sample (getting started) data as follows
user_id | fname | lname
---------+-------+-------
1745 | john | smith
1744 | john | doe
1746 | john | smith
Have I done something wrong?
Thanks
users
table ? – Rikesh$stmt->fetchAll(PDO::FETCH_ASSOC);
& post the array you get ? – Rikesh