Created
February 26, 2013 17:27
-
-
Save thobbs/5040355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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