using UUID1 with phpcassa

被刻印的时光 ゝ 提交于 2019-12-22 14:58:20

问题


Have following CF:

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

then do following code:

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

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


回答1:


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

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

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

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


来源:https://stackoverflow.com/questions/11741284/using-uuid1-with-phpcassa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!