简体   繁体   中英

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.

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM