Skip to content

Instantly share code, notes, and snippets.

@nmmmnu
Created May 17, 2012 22:09
Show Gist options
  • Save nmmmnu/2721873 to your computer and use it in GitHub Desktop.
Save nmmmnu/2721873 to your computer and use it in GitHub Desktop.
Cassandra cqlsh replacement written in php
!/usr/local/bin/php
<?
require_once(__DIR__.'/../lib/autoload.php');
use phpcassa\Connection\ConnectionPool;
if ($argc < 2){
echo "Usage {$argv[0]} keyspace cql\n";
exit;
}
$space = $argv[1];
$cql = $argv[2];
$pool = new ConnectionPool($space, array("127.0.0.1"));
$raw = $pool->get();
$rows = $raw->client->execute_cql_query($cql, 2);
$pool->return_connection($raw);
unset($raw);
$pool->close();
print_r($rows);
//print_r($rows["rows"]); // result data only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment