Skip to content

Instantly share code, notes, and snippets.

@thobbs
Created February 26, 2013 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thobbs/5040355 to your computer and use it in GitHub Desktop.
Save thobbs/5040355 to your computer and use it in GitHub Desktop.
<?php
require_once(__DIR__.'/lib/autoload.php');
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\Index\IndexExpression;
use phpcassa\Index\IndexClause;
$pool = new ConnectionPool('keyspace1', array('127.0.0.1'));
$cf = new ColumnFamily($pool, 'cf3');
// Insert a few records
$cf->insert('key1', array("id" => 1, "postcode" => "foo", "price" => 440));
$cf->insert('key2', array("id" => 2, "postcode" => "bar", "price" => 550));
$cf->insert('key3', array("id" => 3, "postcode" => "baz", "price" => 340));
$ex1 = new IndexExpression("id", 1, "EQ");
$ex2 = new IndexExpression("price", 400, "GT");
$clause = new IndexClause(array($ex1, $ex2));
foreach ($cf->get_indexed_slices($clause) as $key => $columns) {
echo "found something: $key\n";
}
// Close our connections
$pool->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment