我试图用PHP转换Postgres数据库中的表。问题是,当我运行脚本时,我得到null,并且没有提取任何数据。
这是我的代码:
<?php
$connection = pg_connect("host=xxx port=5432 dbname=xxxxx user=xxxxx password=xxxxxxxxx");
$result = pg_query('SELECT * FROM deals');
$rows = array();
while($r = pg_fetch_assoc($result)) {
$rows[] = $r;
}
print json_encode(array_values(pg_fetch_all($result)));
?>
这是代码的实际链接:
答案 0 :(得分:0)
您是否尝试过删除<{p>}之类的null
值
$result = pg_query('SELECT * FROM deals WHERE *filed* != 'null');
或
$result = pg_query('SELECT * FROM deals WHERE *filed* != '');