Cassandra CqlRow fetch DateType / Int32Type
phpcassa library里有个namespace :
use phpcassa\Schema\DataType;
当使用cql query得到cqlrow, int32 & Date type会乱码:
string 'phpcassa\Schema\DataType\Int32Type' (length=34)
string '��09' (length=4)
string 'phpcassa\Schema\DataType\Int32Type' (length=34)
string '��09' (length=4)
string 'phpcassa\Schema\DataType\DateType' (length=33)
string '��:FA�' (length=8)
string 'phpcassa\Schema\DataType\UTF8Type' (length=33)
string '12345' (length=5)
这时,可以用DataType来unpack一下:
$rows = array();
foreach ($cql_result->rows as $rowIndex => $cqlRow) {
$cols = array();
foreach ($cqlRow->columns as $colIndex => $column) {
$type = DataType::get_type_for($cql_result->schema->value_types[$column->name]);
var_dump($type->__toString());
var_dump($column->value);
if($type->__toString() === "phpcassa\Schema\DataType\DateType"){
$cols[$column->name] = date("Y-m-d",$type->unpack($column->value,false));
}else{
$cols[$column->name] = $type->unpack($column->value,false);
} }
$rows[] = $cols;
}
因为我有一个字段在cassandra里是timestamp类型,unpack出来的是time()的毫秒数,转换成date即可。
Cassandra CqlRow fetch DateType / Int32Type的更多相关文章
- Cassandra简介
在前面的一篇文章<图形数据库Neo4J简介>中,我们介绍了一种非常流行的图形数据库Neo4J的使用方法.而在本文中,我们将对另外一种类型的NoSQL数据库——Cassandra进行简单地介 ...
- Golang tool:include spider library,image library and some other db library such as mysql,redis,mogodb,hbase,cassandra
一.Go_tool This is a tool library for Golang.Dont't worry about not understant it! All comment writes ...
- cassandra高级操作之分页的java实现(有项目具体需求)
接着上篇博客,我们来谈谈java操作cassandra分页,需要注意的是这个分页与我们平时所做的页面分页是不同的,具体有啥不同,大家耐着性子往下看. 上篇博客讲到了cassandra的分页,相信大家会 ...
- 开源软件:NoSql数据库 - 图数据库 Cassandra
转载原文:http://www.cnblogs.com/loveis715/p/5299495.html Cassandra简介 在前面的一篇文章<图形数据库Neo4J简介>中,我们介绍了 ...
- cassandra 之 在spark-shell 中使用 spark cassandra connector 完整案例
1.cassandra 准备 启动cqlsh, CQLSH_HOST=172.16.163.131 bin/cqlsh cqlsh>CREATE KEYSPACE productlogs WIT ...
- ASP.NET Core Web API Cassandra CRUD 操作
在本文中,我们将创建一个简单的 Web API 来实现对一个 “todo” 列表的 CRUD 操作,使用 Apache Cassandra 来存储数据,在这里不会创建 UI ,Web API 的测试将 ...
- Git 少用 Pull 多用 Fetch 和 Merge
本文有点长而且有点乱,但就像Mark Twain Blaise Pascal的笑话里说的那样:我没有时间让它更短些.在Git的邮件列表里有很多关于本文的讨论,我会尽量把其中相关的观点列在下面. 我最常 ...
- git提示:Fatal:could not fetch refs from ....
在git服务器上新建项目提示: Fatal:could not fetch refs from git..... 百度搜索毫无头绪,最后FQgoogle,找到这篇文章http://www.voidcn ...
- sublime 插件推荐: Nettuts+ Fetch
Nettuts+ Fetch github地址:Nettuts-Fetch 在sublime中直接用 ctrl+shift+P -> pci -> Nettuts-Fetch 即可下载 这 ...
随机推荐
- PC-如何禁用 Cookie
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* if (string.IsNullOrEmpty(TextBox2.Text) || TextBox2.Tex ...
- Maintainable JavaScript(编写可维护的JavaScript) PART I Style Guidelines
“Programs are meant to be read by humans and only incidentally( 顺便:偶然地:附带地) for computers to execute ...
- oc学习之路----代理模式2-使用步骤
之前已经写过一个个人关于代理模式的一些看法,现在就来总结一下使用代理模式的步骤吧. 1.先搞清楚谁是谁的代理(delegate) ● 2.定义代理协议,协议名称的命名规范:控件类名 + Delegat ...
- IOS 10适配https 包含对于一些http的一些兼容配置
iOS10 从2017年1月1日起苹果提出所有新提交的App默认不允许使用NSAllowsArbitraryLoads来绕过ATS的限制,也就是说强制我们用HTTPS,如果不这样的话提交App可能会被 ...
- JS操作JSON总结(转)
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...
- Deep Learning for NLP 文章列举
Deep Learning for NLP 文章列举 原文链接:http://www.xperseverance.net/blogs/2013/07/2124/ 大部分文章来自: http://w ...
- Docker container network configuration
http://xmodulo.com/networking-between-docker-containers.html How to set up networking between Docker ...
- 观察者模式Demo
using System; using System.Collections.Generic; namespace Demo { #region 抽象层,定义了观察者模式 /// &l ...
- Android 自学之线性布局 LinearLayout
线性布局(LinearLayout),线性布局有点想AWT编程里面的FolwLayout,他们都会将容器里面的组件挨个的排列起来. 他们最大的区别在于:Android的线性布局不会换行:AWT里面的F ...
- 1.Linux系统(CenntOS)固定IP的设定
首先:我们配置一个临时的固定的固定ip,作用是让我们用其他的shell工具连接虚拟机 ifconfig eth0 192.168.10.168 在主机用ping命令查询连通后再进行下一步 ping 1 ...