I have been using Cassandra the past few days. For this, I use the PHPCassa library.
When I try to use the following code, it does not work correctly.
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);
Without returning anything, I also tried the following queries
$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);
But when I tried
$rows = $raw->client->execute_cql_query("SELECT * FROM User", cassandra_Compression::NONE);
He gave the correct answer, displayed all the lines. Please advise me how to use "WHERE" correctly.
Keyspace Information
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
source share