pg_prepare(): Query failed: ERROR: Relation does not exist

pg_prepare(): Query failed: ERROR: Relation does not exist

我正在尝试使用 PHP 在 Postgres 数据库上执行查询。我收到以下错误:

pg_prepare(): Query failed: ERROR: relation "login" does not exist LINE 1: SELECT * FROM login 

这是我的代码片段:

$connString = "host= port= dbname= user=password=";
$conn = pg_connect($connString);
if ($conn) {
    $sql = 'SELECT * FROM login ';
    if (pg_prepare($conn, "myQuery", $sql)) {
        $result = pg_execute($conn, "myQuery", array());
        if ($result) {
            while ($row = pg_fetch_row($result)) {

                echo $row[0];

                echo $row[1];
            }
        } else {
            echo 'executing error!';
        }
    } else {
        echo 'preparing error!';
    }
} else {
    echo "Connection error!";
}
if ($conn) {
    pg_close($conn);
}

当我运行这个脚本时,它也会打印'preparing error!'

我想数据库中发生了一些事情。 我试图创建一个新的 table。我也尝试在多个地方的查询中使用引号,但没有任何效果。

这是我用来创建数据库的查询:

CREATE TABLE login
(
    user_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
    username character varying(50) COLLATE pg_catalog."default",
    pwd character varying(50) COLLATE pg_catalog."default",
    CONSTRAINT pk_user_id PRIMARY KEY (user_id)
)

我该如何解决这个问题?

尝试

SELECT * FROM public."login"