php - Cassandra 时间戳

标签 php database nosql cassandra phpcassa

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)
}

有什么想法吗?

最佳答案

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

$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”创建一个新列,其中每个列名都是 birthday:uuid 以保持唯一性。

关于php - Cassandra 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6485449/

相关文章:

php - zend_db 的问题

php - 安全地允许通过 MIME TYPES/fil 上传网络字体(ttf、eot、svg、woff、otf)

php - 空 DATETIME 值存储为 0000-00-00 00 :00:00 instead of NULL in MySQL

c# - 数据库、请求、性能、缓存

database - PostgreSQL 中的 PGDATA 是什么

mongodb - 电子商务/购物车(和结帐流程): use Relational or NoSQL

php - 适用于写读密集型站点的良好 NoSQL 数据库

php - 数据库日志与文件日志

database - 数据库设计中外键真的有必要吗?

mongodb - 将数亿个小图像存储到键/值存储或其他 nosql 数据库是个好主意吗?