{"id":3039,"date":"2021-07-21T12:29:37","date_gmt":"2021-07-21T12:29:37","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=3039"},"modified":"2021-07-21T12:29:38","modified_gmt":"2021-07-21T12:29:38","slug":"postgresql-interfejs-php","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/uk\/postgresql-interfejs-php\/","title":{"rendered":"PostgreSQL \u2014 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 PHP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 PostgreSQL \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 PHP 5.3.x.&nbsp;\u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f&nbsp;<strong>\u2014without-pgsql<\/strong>&nbsp;\u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.&nbsp;\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 yum \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 PHP-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 PostgreSQL \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install php-pgsql<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b \u043d\u0430\u0447\u043d\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 PHP PostgreSQL, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0444\u0430\u0439\u043b&nbsp;<strong>pg_hba.conf<\/strong>&nbsp;\u0432 \u0432\u0430\u0448\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 PostgreSQL \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># IPv4 local connections:\nhost    all         all         127.0.0.1\/32          md5<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \/ \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 postgres, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@host]# service postgresql restart\nStopping postgresql service:                               [  OK  ]\nStarting postgresql service:                               [  OK  ]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 Windows \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c php_pgsql.dll, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435.&nbsp;\u042d\u0442\u0430 DLL \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u044b Windows \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 PHP 5.3.x<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430\u0448 \u0443\u0447\u0435\u0431\u043d\u0438\u043a \u043f\u043e PHP \u0438 \u0435\u0433\u043e \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">API \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 PHP<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u0430\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b PHP, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u0430\u0448\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL \u0438\u0437 \u0432\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b PHP.&nbsp;\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0449\u0435\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e PHP.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u0421. \u041d\u0435\u0442.<\/th><th>API \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/th><\/tr><tr><td>1<\/td><td><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_connect (\u0441\u0442\u0440\u043e\u043a\u0430 $ connection_string [, int $ connect_type])<\/strong>\u042d\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 connection_string.\u0415\u0441\u043b\u0438 PGSQL_CONNECT_FORCE_NEW \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a connect_type, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 pg_connect (), \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430_\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044e.<\/td><\/tr><tr><td>2<\/td><td><strong>bool pg_connection_reset (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435)<\/strong>\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435.&nbsp;\u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u0448\u0438\u0431\u043e\u043a.&nbsp;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 TRUE \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0445\u0430 \u0438\u043b\u0438 FALSE \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438.<\/td><\/tr><tr><td>3<\/td><td><strong>int pg_connection_status (\u0440\u0435\u0441\u0443\u0440\u0441 $ connection)<\/strong>\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.&nbsp;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 PGSQL_CONNECTION_OK \u0438\u043b\u0438 PGSQL_CONNECTION_BAD.<\/td><\/tr><tr><td>4<\/td><td><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_dbname ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435])<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f PostgreSQL.<\/td><\/tr><tr><td>5<\/td><td><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_prepare ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ stmtname, \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0437\u0430\u043f\u0440\u043e\u0441)<\/strong>\u042d\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f.<\/td><\/tr><tr><td>6<\/td><td><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_execute ([\u0440\u0435\u0441\u0443\u0440\u0441 $ connection], \u0441\u0442\u0440\u043e\u043a\u0430 $ stmtname, \u043c\u0430\u0441\u0441\u0438\u0432 $ params)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/td><\/tr><tr><td>7<\/td><td><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_query ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0437\u0430\u043f\u0440\u043e\u0441)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/td><\/tr><tr><td>8<\/td><td><strong>\u043c\u0430\u0441\u0441\u0438\u0432 pg_fetch_row (\u0440\u0435\u0441\u0443\u0440\u0441 $ result [, int $ row])<\/strong>\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/td><\/tr><tr><td>9<\/td><td><strong>\u043c\u0430\u0441\u0441\u0438\u0432 pg_fetch_all (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0437\u0430\u043f\u0438\u0441\u0438) \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435.<\/td><\/tr><tr><td>10<\/td><td><strong>int pg_affered_rows (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 INSERT, UPDATE \u0438 DELETE.<\/td><\/tr><tr><td>11<\/td><td><strong>int pg_num_rows (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435 PostgreSQL, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c SELECT.<\/td><\/tr><tr><td>12<\/td><td><strong>bool pg_close ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435])<\/strong>\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/td><\/tr><tr><td>13<\/td><td><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_last_error ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435])<\/strong>\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/td><\/tr><tr><td>14<\/td><td><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_escape_literal ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0434\u0430\u043d\u043d\u044b\u0435)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u043b\u0438\u0442\u0435\u0440\u0430\u043b \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435.<\/td><\/tr><tr><td>15<\/td><td><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_escape_string ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0434\u0430\u043d\u043d\u044b\u0435)<\/strong>\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_connect (\u0441\u0442\u0440\u043e\u043a\u0430 $ connection_string [, int $ connect_type])<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 connection_string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0415\u0441\u043b\u0438 PGSQL_CONNECT_FORCE_NEW \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a connect_type, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 pg_connect (), \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430_\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044e.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>bool pg_connection_reset (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435.&nbsp;\u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u0448\u0438\u0431\u043e\u043a.&nbsp;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 TRUE \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0445\u0430 \u0438\u043b\u0438 FALSE \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>int pg_connection_status (\u0440\u0435\u0441\u0443\u0440\u0441 $ connection)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.&nbsp;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 PGSQL_CONNECTION_OK \u0438\u043b\u0438 PGSQL_CONNECTION_BAD.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_dbname ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435])<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f PostgreSQL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_prepare ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ stmtname, \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0437\u0430\u043f\u0440\u043e\u0441)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_execute ([\u0440\u0435\u0441\u0443\u0440\u0441 $ connection], \u0441\u0442\u0440\u043e\u043a\u0430 $ stmtname, \u043c\u0430\u0441\u0441\u0438\u0432 $ params)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0440\u0435\u0441\u0443\u0440\u0441 pg_query ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0437\u0430\u043f\u0440\u043e\u0441)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u043c\u0430\u0441\u0441\u0438\u0432 pg_fetch_row (\u0440\u0435\u0441\u0443\u0440\u0441 $ result [, int $ row])<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u043c\u0430\u0441\u0441\u0438\u0432 pg_fetch_all (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0437\u0430\u043f\u0438\u0441\u0438) \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>int pg_affered_rows (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 INSERT, UPDATE \u0438 DELETE.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>int pg_num_rows (\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435 PostgreSQL, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c SELECT.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>bool pg_close ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435])<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_last_error ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435])<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_escape_literal ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0434\u0430\u043d\u043d\u044b\u0435)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u043b\u0438\u0442\u0435\u0440\u0430\u043b \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0441\u0442\u0440\u043e\u043a\u0430 pg_escape_string ([\u0440\u0435\u0441\u0443\u0440\u0441 $ \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435], \u0441\u0442\u0440\u043e\u043a\u0430 $ \u0434\u0430\u043d\u043d\u044b\u0435)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 PHP \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435, \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $host        = \"host = 127.0.0.1\";\n   $port        = \"port = 5432\";\n   $dbname      = \"dbname = testdb\";\n   $credentials = \"user = postgres password=pass123\";\n\n   $db = pg_connect( \"$host $port $dbname $credentials\"  );\n   if(!$db) {\n      echo \"Error : Unable to open database\\n\";\n   } else {\n      echo \"Opened database successfully\\n\";\n   }\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445&nbsp;<strong>testdb<\/strong>&nbsp;: \u0435\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u0430, \u043e\u043d\u0430 \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Opened database successfully\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 PHP \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $host        = \"host = 127.0.0.1\";\n   $port        = \"port = 5432\";\n   $dbname      = \"dbname = testdb\";\n   $credentials = \"user = postgres password=pass123\";\n\n   $db = pg_connect( \"$host $port $dbname $credentials\"  );\n   if(!$db) {\n      echo \"Error : Unable to open database\\n\";\n   } else {\n      echo \"Opened database successfully\\n\";\n   }\n   \n   $sql =&lt;&lt;&lt;EOF\n      CREATE TABLE COMPANY\n      (ID INT PRIMARY KEY     NOT NULL,\n      NAME           TEXT    NOT NULL,\n      AGE            INT     NOT NULL,\n      ADDRESS        CHAR(50),\n      SALARY         REAL);\nEOF;\n\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n   } else {\n      echo \"Table created successfully\\n\";\n   }\n   pg_close($db);\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u043e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 COMPANY \u0432 \u0432\u0430\u0448\u0435\u0439&nbsp;<strong>\u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>&nbsp;\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Opened database successfully\nTable created successfully\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0412\u0421\u0422\u0410\u0412\u0418\u0422\u042c \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 PHP \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 COMPANY, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $host        = \"host=127.0.0.1\";\n   $port        = \"port=5432\";\n   $dbname      = \"dbname = testdb\";\n   $credentials = \"user = postgres password=pass123\";\n\n   $db = pg_connect( \"$host $port $dbname $credentials\"  );\n   if(!$db) {\n      echo \"Error : Unable to open database\\n\";\n   } else {\n      echo \"Opened database successfully\\n\";\n   }\n\n   $sql =&lt;&lt;&lt;EOF\n      INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)\n      VALUES (1, 'Paul', 32, 'California', 20000.00 );\n\n      INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)\n      VALUES (2, 'Allen', 25, 'Texas', 15000.00 );\n\n      INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)\n      VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );\n\n      INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)\n      VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );\nEOF;\n\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n   } else {\n      echo \"Records created successfully\\n\";\n   }\n   pg_close($db);\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u043e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 COMPANY \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Opened database successfully\nRecords created successfully\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0412\u042b\u0411\u0415\u0420\u0418\u0422\u0415 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044e<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 PHP \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b COMPANY, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $host        = \"host = 127.0.0.1\";\n   $port        = \"port = 5432\";\n   $dbname      = \"dbname = testdb\";\n   $credentials = \"user = postgres password=pass123\";\n\n   $db = pg_connect( \"$host $port $dbname $credentials\"  );\n   if(!$db) {\n      echo \"Error : Unable to open database\\n\";\n   } else {\n      echo \"Opened database successfully\\n\";\n   }\n\n   $sql =&lt;&lt;&lt;EOF\n      SELECT * from COMPANY;\nEOF;\n\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n      exit;\n   } \n   while($row = pg_fetch_row($ret)) {\n      echo \"ID = \". $row[0] . \"\\n\";\n      echo \"NAME = \". $row[1] .\"\\n\";\n      echo \"ADDRESS = \". $row[2] .\"\\n\";\n      echo \"SALARY =  \".$row[4] .\"\\n\\n\";\n   }\n   echo \"Operation done successfully\\n\";\n   pg_close($db);\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043e\u043d\u0430 \u0434\u0430\u0441\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.&nbsp;\u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Opened database successfully\nID = 1\nNAME = Paul\nADDRESS = California\nSALARY =  20000\n\nID = 2\nNAME = Allen\nADDRESS = Texas\nSALARY =  15000\n\nID = 3\nNAME = Teddy\nADDRESS = Norway\nSALARY =  20000\n\nID = 4\nNAME = Mark\nADDRESS = Rich-Mond\nSALARY =  65000\n\nOperation done successfully\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u041e\u0411\u041d\u041e\u0412\u041b\u0415\u041d\u0418\u0415 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 PHP \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 UPDATE \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b COMPANY \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $host        = \"host=127.0.0.1\";\n   $port        = \"port=5432\";\n   $dbname      = \"dbname = testdb\";\n   $credentials = \"user = postgres password=pass123\";\n\n   $db = pg_connect( \"$host $port $dbname $credentials\"  );\n   if(!$db) {\n      echo \"Error : Unable to open database\\n\";\n   } else {\n      echo \"Opened database successfully\\n\";\n   }\n   $sql =&lt;&lt;&lt;EOF\n      UPDATE COMPANY set SALARY = 25000.00 where ID=1;\nEOF;\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n      exit;\n   } else {\n      echo \"Record updated successfully\\n\";\n   }\n   \n   $sql =&lt;&lt;&lt;EOF\n      SELECT * from COMPANY;\nEOF;\n\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n      exit;\n   } \n   while($row = pg_fetch_row($ret)) {\n      echo \"ID = \". $row[0] . \"\\n\";\n      echo \"NAME = \". $row[1] .\"\\n\";\n      echo \"ADDRESS = \". $row[2] .\"\\n\";\n      echo \"SALARY =  \".$row[4] .\"\\n\\n\";\n   }\n   echo \"Operation done successfully\\n\";\n   pg_close($db);\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u043e\u043d\u0430 \u0434\u0430\u0441\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Opened database successfully\nRecord updated successfully\nID = 2\nNAME = Allen\nADDRESS = 25\nSALARY =  15000\n\nID = 3\nNAME = Teddy\nADDRESS = 23\nSALARY =  20000\n\nID = 4\nNAME = Mark\nADDRESS = 25\nSALARY =  65000\n\nID = 1\nNAME = Paul\nADDRESS = 32\nSALARY =  25000\n\nOperation done successfully\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0423\u0414\u0410\u041b\u0415\u041d\u0418\u0415 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 PHP \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e DELETE, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b COMPANY \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $host        = \"host = 127.0.0.1\";\n   $port        = \"port = 5432\";\n   $dbname      = \"dbname = testdb\";\n   $credentials = \"user = postgres password=pass123\";\n\n   $db = pg_connect( \"$host $port $dbname $credentials\"  );\n   if(!$db) {\n      echo \"Error : Unable to open database\\n\";\n   } else {\n      echo \"Opened database successfully\\n\";\n   }\n   $sql =&lt;&lt;&lt;EOF\n      DELETE from COMPANY where ID=2;\nEOF;\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n      exit;\n   } else {\n      echo \"Record deleted successfully\\n\";\n   }\n   \n   $sql =&lt;&lt;&lt;EOF\n      SELECT * from COMPANY;\nEOF;\n\n   $ret = pg_query($db, $sql);\n   if(!$ret) {\n      echo pg_last_error($db);\n      exit;\n   } \n   while($row = pg_fetch_row($ret)) {\n      echo \"ID = \". $row[0] . \"\\n\";\n      echo \"NAME = \". $row[1] .\"\\n\";\n      echo \"ADDRESS = \". $row[2] .\"\\n\";\n      echo \"SALARY =  \".$row[4] .\"\\n\\n\";\n   }\n   echo \"Operation done successfully\\n\";\n   pg_close($db);\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 PostgreSQL \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 PHP 5.3.x.&nbsp;\u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f&nbsp;\u2014without-pgsql&nbsp;\u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.&nbsp;\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[104],"tags":[],"class_list":["post-3039","page","type-page","status-publish","hentry","category-postgresql"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/3039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/comments?post=3039"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/3039\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/media?parent=3039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/categories?post=3039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/tags?post=3039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}