【问题标题】:How to fetch columns in reverse order with PHPCassa如何使用 PHPCassa 以相反的顺序获取列
【发布时间】:2012-06-04 23:47:41
【问题描述】:

如何使用 PHPCassa 以相反的顺序获取单行中的列?

【问题讨论】:

    标签: cassandra phpcassa


    【解决方案1】:

    来自 phpcassa 文档

     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)
    

    参见“@param bool $column_reversed 以相反的顺序获取列”

    将此参数设置为“true”将以相反的顺序获取列。

    您甚至可以为 multiget、get_range 和 get_indexed_slices 查询设置此参数。

    更多详情请见:phpcassa columnfamily documentation

    【讨论】:

    【解决方案2】:

    技巧是用空列切片对象完成的。

    ...
    
    $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);
    

    【讨论】:

      猜你喜欢
      • 2015-05-20
      • 2021-10-13
      • 2012-11-29
      • 1970-01-01
      • 2018-10-05
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 2012-03-15
      相关资源
      最近更新 更多