我正在尝试连接并从PostgreSQL服务器中选择数据。我能够连接到服务器,但我的选择查询似乎运行错误。有什么建议吗?
<?php
$conn = "host=#### port=5432 dbname=consolidated user=#### password=####";
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$dbconn = pg_connect($conn);
$result = pg_query($dbconn, "SELECT id FROM retailer_retailer;");
if (!$result) {
echo "An error occurred.\n";
exit;
}
while ($row = pg_fetch_row($result)) {
echo "ID: $row[0]";
echo "<br />\n";
}
?>
答案 0 :(得分:1)
你错过了这里的模式名称,我假设你在公共模式中有表,你的查询应该是 -
$result = pg_query($dbconn, "SELECT id FROM public.retailer_retailer;");
如果您有其他架构,则可以将public替换为其他架构名称