我最近几天在使用 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