Question

How to fetch the columns in a single row in reverse order with PHPCassa?

Was it helpful?

Solution 2

Trick is done with empty column slice object.

...

$cf = new ColumnFamily($pool, 'mycolumnfamily');

// normal order
$rows = $cf->get('mykey'); 

print_r($rows);

// reverse order, 5 is column count, true is reverse order
$rows = $cf->get('mykey', new ColumnSlice(null, null, 5, true) );

print_r($rows);

OTHER TIPS

From phpcassa documentation

 public function get($key,
                     $columns=null,
                     $column_start="",
                     $column_finish="",
                     $column_reversed=False,
                     $column_count=self::DEFAULT_COLUMN_COUNT,
                     $super_column=null,
                     $read_consistency_level=null)

See "@param bool $column_reversed fetch the columns in reverse order"

Setting this parameter to "true" will fetch the columns in reverse order.

You can even set this parameter for multiget, get_range and get_indexed_slices queries.

For More Detail see: phpcassa columnfamily documentation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top