我无法将postgresql数组转换为php数组。下面是我的数组列是字符varying[],下面是值{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];
发布于 2013-06-24 19:24:36
这就完成了。
preg_match('/^{(.*)}$/', $row["images"], $matches);
$imgArry=str_getcsv($matches[1]);
https://stackoverflow.com/questions/17283026
复制