Search code examples
cassandraphpcassa

How to fetch columns in reverse order with PHPCassa


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


Solution

  • 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);