【发布时间】:2013-03-04 01:17:41
【问题描述】:
我最近几天在使用 Cassandra。我为此使用 PHPCassa 库。
当我尝试使用以下代码时,它无法正常工作。
require_once('phpcassa/connection.php');
require_once "phpcassa/columnfamily.php";
// Create new ConnectionPool like you normally would
$pool = new ConnectionPool("newtest");
// Retrieve a raw connection from the ConnectionPool
$raw = $pool->get();
$rows = $raw->client->execute_cql_query("SELECT * FROM User WHERE KEY='phpqa'", cassandra_Compression::NONE);
echo "<pre>";
print_r($rows);
echo "<pre>";
// Return the connection to the pool so it may be used by other callers. Otherwise,
// the connection will be unavailable for use.
$pool->return_connection($raw);
unset($raw);
它什么也没返回,我也尝试过以下查询
$rows = $raw->client->execute_cql_query("SELECT * FROM User WHERE age='32'", cassandra_Compression::NONE);
$rows = $raw->client->execute_cql_query("SELECT * FROM User WHERE name='jack'", cassandra_Compression::NONE);
但是当我尝试时
$rows = $raw->client->execute_cql_query("SELECT * FROM User", cassandra_Compression::NONE);
给出正确答案,显示所有行。请告诉我,如何正确使用“WHERE”。
键空间详细信息
Strategy Class: org.apache.cassandra.locator.SimpleStrategy
Strategy Options: None
Replication Factor: 1
Ring
Start Token: 6064078270600954295
End Token: 6064078270600954295
Endpoints: 127.0.0.1
【问题讨论】:
-
'DESCRIBE USER KEYSPACE' 的输出是什么?
-
“年龄”和“姓名”是否已编入索引?
-
在此查询“SELECT * FROM User WHERE KEY='phpqa'”中,phpqa 是该行数据的键名。
-
我们需要为此索引 KEY 吗?
标签: php cassandra cql phpcassa