时时商务社区
标题:
PHP 读取Postgresql中的数组
[打印本页]
作者:
yj1281
时间:
2018-2-14 08:22
[U]复制代码[/U] 代码如下:
function getarray_postgresql($arraystr)
{
$regx1 = '/^{(.*)}$/';
$regx2 = "/\"((\\\\\\\\|\\\\\"|[^\"])+)\"|[^,]+/";
$regx3 = '/^[^"].*$|^"(.*)"$/';
$match = null;
preg_match( $regx1,$arraystr,$match);
$str = $match[1];
preg_match_all($regx2, $str,$match);
$items = $match[0];
$array = array();
$count = count($items);
for($index = 0; $index
在PHP从postgresql中读取的数据都是字符串的,一般的数据还好处理,但是postgresql有一种数组型的数据,而如果我们的数组是字符串的,前且,里面有逗号或斜线也是可能的,这就给我们读取带来了一定的麻烦,上面的函数是我奋斗了几个小时写出来的。尽可能的考虑到了斜线,逗号,引号的存在。
您可能感兴趣的文章:
Windows PostgreSQL 安装图文教程
C#访问PostGreSQL数据库的方法
PostgreSQL 角色与用户管理介绍
举例简单介绍PostgreSQL中的数组
简单介绍Ruby on Rails对PostgreSQL数组类型的支持
在PostgreSQL中使用数组时值得注意的一些地方
图文详解mybatis+postgresql平台搭建步骤
Linux CentOS 7安装PostgreSQL9.3图文教程
Linux CentOS 7源码编译安装PostgreSQL9.5
Mybatis调用PostgreSQL存储过程实现数组入参传递
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2