我正在使用cql3.0.0
我已执行查询:
INSERT INTO emp (empID, deptID, first_name, last_name)
VALUES (104, 15, 'jane', 'smith')
检索此记录时,我得到以下值:
empid = h
deptid = (blank value)
first_name = 'jane'
last_name = 'smith'
在搜索它时,我发现h相当于utf-8字符104。utf-8中的15也是空白(参考链接:http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec&unicodeinhtml=dec )
在create table期间,我将列类型设置为int,但是在检索时,我没有得到int值。
如何获取要检索的正确值。我不想要utf-8值。
谢谢
我使用的是Cassandra1.2.4
下面是我用phpcassa编写的代码:
require_once(__DIR__.'/../lib/autoload.php');
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
use cassandra\Compression;
use cassandra\ConsistencyLevel;
$pool = new ConnectionPool("prod",array('X.X.X.X','X.X.X.X'));
$raw = $pool->get();
$rows = $raw->client->set_cql_version("3.0.0");
$rows = $raw->client->execute_cql3_query('USE prod;', Compression::NONE, ConsistencyLevel::ONE );
$rows = $raw->client->execute_cql3_query('CREATE TABLE emp (
empID int,
deptID int,
first_name varchar,
last_name varchar,
PRIMARY KEY (empID, deptID));
', Compression::NONE, ConsistencyLevel::ONE );
$rows = $raw->client->execute_cql3_query('INSERT INTO emp (empID, deptID, first_name, last_name)
VALUES (104, 15, \'jane\', \'smith\');
', Compression::NONE, ConsistencyLevel::ONE );
$rows = $raw->client->execute_cql3_query('SELECT * FROM emp WHERE empID IN (2,104) ORDER BY deptID ASC;', Compression::NONE, ConsistencyLevel::ONE );
echo "<pre>";
print_r($rows);
echo "<pre>";
生成的输出为:
cassandra\CqlRow Object
(
[key] =>
[columns] => Array
(
[0] => cassandra\Column Object
(
[name] => empid
[value] => h
[timestamp] =>
[ttl] =>
)
[1] => cassandra\Column Object
(
[name] => deptid
[value] =>
[timestamp] =>
[ttl] =>
)
[2] => cassandra\Column Object
(
[name] => first_name
[value] => jane
[timestamp] =>
[ttl] =>
)
[3] => cassandra\Column Object
(
[name] => last_name
[value] => smith
[timestamp] =>
[ttl] =>
)
)
)
2条答案
按热度按时间kcugc4gi1#
我会说,请审查你的解决方案,我已经尝试了完全相同的事情,你描述为你的问题,但它的工作对我来说是正常的。可能是在创建时,您使用了utf-8作为它们的类型。
架构
插入
检索
vyswwuz22#
虽然回答得有点晚,但我在为yii框架编写自己的cassandra Package 时,正在拼命寻找解决方案。我提出了类似以下类的方法,消除了cassandra中不同数据类型(包括整数类型)的不正确二进制的问题: