Datastax Cassandra PHP驱动程序:在准备好的语句

时间:2016-03-16 11:35:56

标签: php cassandra prepared-statement datastax timeuuid

我正在尝试使用timeuuid值执行预准备语句并获取“无效值类型”异常。

以下是代码:

$builder = \Cassandra::cluster();
$cluster = $builder->withContactPoints('127.0.0.1')
            ->build();

$session = $cluster->connect();
$preparedStatement = $session->prepare("SELECT * FROM test.timeuuid_test WHERE account_id = :accId and item_time_uid >= minTimeuuid(:minTime);");
$options = new ExecutionOptions([
            'arguments' => [
                'accId' => 1234,
                'minTime' => new \Cassandra\Timeuuid(1458118516)
            ]
        ]);
$session->execute($preparedStatement, $options);

我得到以下异常:

  

“Cassandra \ Exception \ InvalidArgumentException:无效的值类型”

以下是表格方案:

CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1 };

CREATE TABLE test.timeuuid_test (
  account_id int,
  item_time_uid timeuuid,
  PRIMARY KEY ((account_id), item_time_uid)
) WITH CLUSTERING ORDER BY (item_time_uid DESC);

我做错了什么?

我正在使用PECL cassandra 1.1.0和cassandra 2.0.15:

安装cassandra相关包: cassandra20-2.0.15-1.noarch 卡桑德拉-CPP-司机2.2.2-1.el6.x86_64 卡桑德拉-CPP-驾驶员devel的-2.2.2-1.el6.x86_64

1 个答案:

答案 0 :(得分:2)

您将错误的类型绑定到minTimeminTimeUuid需要timestamp个参数,而不是timeuuid