0
我試圖用PHP轉換Postgres數據庫中的表。事情是,我在運行腳本時得到空值,並且沒有數據被提取。將Postgres數據庫轉換爲JSON時變爲空
這裏是我的代碼:
<?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)));
?>
這是實際的鏈接代碼:
http://send.easyrent-brasil.com/api.php
您正在'$ rows'中構建結果數組,但似乎忽略它並調用'pg_fetch_all'。你應該可以做一個或另一個。 – IMSoP
我改變了一些代碼 http://send.easyrent-brasil.com/api.php 但現在它不打印任何東西 –