Search code examples
phpcassandraphpcassa

Get value from Cassandra with PHPCASSA


I recently switched to PHPCassa to manage db connection in my PHP platform.

This is the code i'm using:

$indexExpression = new IndexExpression("Username", $username);
$indexClause = new IndexClause(array($indexExpression));
$cf = new ColumnFamily($this->cassandra, "Users");
$rows = $cf->get_indexed_slices($indexClause);

The problem is that actually $rows is not an array containing the data i'd like to fetch but it contains an IndexedColumnFamilyIterator object.

I'm I doing something wrong?

Thanks for helping.


Solution

  • Since you already cross-posted to the user mailing list (tisk, tisk :), I'll link to the answer and copy the answer here for others: https://groups.google.com/forum/?fromgroups#!topic/phpcassa/RrYTQc_jQ7s


    It returns an iterator so that it can break up the query into manageable chunks (100 rows, by default) automatically.

    $row_iterator = $cf->get_indexed_slices($indexClause);
    foreach ($row_iterator as $key => $columns) {
        // do stuff
    }