1

SELECT * FROM table_name WHERE date > 1309110123

如何在 Phpcassa 中做到这一点?我认为必须有一些方法来修改它:

$column_family = new ColumnFamily($conn, 'Indexed1');
$index_exp = CassandraUtil::create_index_expression('birthdate', 1984);
$index_clause = CassandraUtil::create_index_clause(array($index_exp));
$rows = $column_family->get_indexed_slices($index_clause);
// returns an Iterator over:
//    array('winston smith' => array('birthdate' => 1984))

foreach($rows as $key => $columns) {
    // Do stuff with $key and $columns
    Print_r($columns)
}

任何人的想法?

4

1 回答 1

3

我会建议您使用上述方法的替代方法。最简单的方法是将行键的记录作为列存储在另一行中,如下所示:

$date = new DateTime();
$cf = new ColumnFamily(getCassandraConnection(), 'foobar');
$cf->insert('row1' => array('foo' => 'bar'));
$cf->insert('all_rows' => array($date->getTimestamp() => 'row1');

现在,当您想要进行选择时,就像您在上面所做的那样,使用 PHPCASSA,您可以简单地使用 column_start / column_end 进行获取:

$newerResults = $cf->get('all_rows', $columns=null, $column_start=1309110123);

在生日的情况下,就像从 RDBMS 世界看起来一样丑陋,在一行中为“user_birthdates”创建一个新列,其中每个列名都是生日:uuid,以保持事物的唯一性。

于 2011-06-26T17:28:31.123 回答