使用UUID1与phpcassa [英] using UUID1 with phpcassa

查看:153
本文介绍了使用UUID1与phpcassa的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有以下CF:

create column family gr_ip2
with column_type = 'Standard' and comparator = 'TimeUUIDType(reversed=true)' ...;

然后执行以下代码:

$uuid1 = phpcassa\UUID::uuid1(null, $time);
$cf->insert("$key"  , array($uuid1 => $url) );

它没有例外,但结尾的CF为空。

it works without exceptions, but CF at the end is empty.

推荐答案

$ uuid1不是字符串,而是一个对象。当我们执行

$uuid1 is not string, but an object. When we do

$cf->insert("$key"  , array($uuid1 => $url) );

对象转换为字符串,并且插入失败。
phpcassa没有给出exeption,但插入失败。

the object is converted to string, and insert fails. phpcassa does not give exeption, but insert fails anyway.

看起来像我们需要使用ARRAY_FORMAT,所以对象不是flatten

Seems like we need to use ARRAY_FORMAT, so the object not to be "flatten" to string,

$uuid1 = phpcassa\UUID::uuid1(null, $time);

$cf->insert_format = phpcassa\ColumnFamily::ARRAY_FORMAT;

$cf->insert("$key"  , array(
      array($uuid1, $url)
) );

这篇关于使用UUID1与phpcassa的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆