0
檢索卡桑德拉表複合列我有一個檢索行查詢一個CassandraHandler如何在PHP
class CassandraHandler
{
private $keyspace = 'blabla'; //default is oyvent
private $cluster = NULL;
private $session = NULL;
function __construct(){
$this->cluster = \Cassandra::cluster()
->build(); // connects to localhost by default
$this->session = $this->cluster->connect($this->keyspace);
}
/**
* @return Rows
*/
public function execute($query){
$statement = new \Cassandra\SimpleStatement($query);
$result = $this->session->execute($statement);
return $result;
}
}
當我使用正常的列這很好,但我不能在PHP
得到我的照片列我創造了這樣的
photos frozen<set<map<text,text>>>
的json例子列
{{"urllarge": "1.jpg", "urlmedium": "2.jpg"},
{"urllarge": "3.jpg", "urlmedium": "4.jpg"}}
在這裏如何使用PHP來檢索組合列?
$cassandraHandler = new CassandraHandlerClass();
$rows = $cassandraHandler->fetchLatestPosts($placeids, $limit);
foreach ($rows as $row) {
$tmp = array();
$tmp["userid"] = doubleval($row["userid"]);
$tmp["fullname"] = $row["fullname"];
$tmp["photos"] = $row["photos"] //????????
}
我知道有一個PHP的司機https://github.com/datastax/php-driver
的這個文檔,但我有點困惑。我只需要獲得json的價值就像我在cqlsh得到
看來'{{「urllarge」:「1.jpg」,「urlmedium」:「2.jpg」}, {「urllarge」:「3.jpg」,「urlmedium」:「4.jpg」 }}'是一個無效的json。你可以請傾倒整行嗎? – ruhul