Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 查询postgresql数组列_Php_Postgresql - Fatal编程技术网

Php 查询postgresql数组列

Php 查询postgresql数组列,php,postgresql,Php,Postgresql,我无法将postgresql数组转换为php数组。 这是我的数组 列为字符变化[],以下是值 {image1,image2,image3} $imgArry始终为空 $query = "SELECT \"A\".\"id\", array_to_json(\"A\".images) FROM public.A " ; $rs = pg_query($db, $query) or

我无法将postgresql数组转换为php数组。 这是我的数组 列为字符变化[],以下是值 {image1,image2,image3}

$imgArry始终为空

$query = "SELECT \"A\".\"id\",
                array_to_json(\"A\".images)
                 FROM 
                public.A " ;

    $rs = pg_query($db, $query) or
            die("Cannot execute query: $query\n");
    $index = 0;
    while ($row = pg_fetch_assoc($rs)) {
        $A->id = $row["id"];

        $imgArry = json_decode($row["images"]);
        $planproduct->image=$imgArry[0];
就这样

 preg_match('/^{(.*)}$/', $row["images"], $matches);
 $imgArry=str_getcsv($matches[1]);
就这样

 preg_match('/^{(.*)}$/', $row["images"], $matches);
 $imgArry=str_getcsv($matches[1]);

这不是对斜杠表达式的免疫
str\u getcsv(str\u replace(“\\\\”,“\\\”,trim($data,“{}”))
is。这不适用于斜杠表达式
str\u getcsv(str\u replace('\\\','\\',trim($data,“{}”))
is。