Home >Backend Development >PHP Tutorial >php connection postgreSql

php connection postgreSql

WBOY
WBOYOriginal
2016-07-29 08:56:462731browse

S Environment: wampserver64 pHP5.5.12

1. Remove the comma before the extension = php_pdo_pdo_pgsql.dll and extension = php_pgsql.dll; .dll
(libpq.dll under the php folder) and

./php/ext/php_pgsql.dll(php_pgsql.dll under the ext folder)php_pdo_pgsql.dllThese 3 dlls Copy the file to the C drive system32 3.Normally, php can connect to postgres, but I still get an error, prompting "Fatal error: Call to undefined function pg_connect()", check Apache's log, "PHP Startup: Unable to load dynamic library '****\PHP5\ext\php_pdo_pgsql.dll".

After searching, conf in Apache Add LoadFile "***/PHP5/libpq.dll" to the configuration file httpd.conf under the folder, and the location is after LoadModule (*** is the php installation path) 4. Test code

<?php
$conn_string  =  "host=localhost port=5432 dbname=db_name user=your user password=your password" ; 
$dbconn = pg_connect($conn_string);
if (!$dbconn) 
    echo "连接失败!!!!!/r/n";
else 
    echo "连接成功!!!!!/r/n";
    pg_close($dbconn);
?>
Original link:http://www.cnblogs.com/FlyFive/archive/2013/03/11/2954686.html

http://blog.csdn.net/yageeart/article/details/6674296

The above introduces the PHP connection to postgreSql, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn