dqellle310167
2015-06-04 16:13
浏览 81
已采纳

macdo x yosemite上的pdo_pgsql和php

So I compiled pdo_pgsql from source and added the extension to my php.ini

phpinfo()

says

PDO

PDO support enabled
PDO drivers mysql, sqlite, pgsql

pdo_pgsql

PDO Driver for PostgreSQL   enabled
PostgreSQL(libpq) Version   9.4.2
Module version  1.0.2

but

pg_connect("host=localhost dbname=dbname user=username password=password")

gives

Call to undefined function pg_connect()

Yes, I did restart apache.

SERVER_SOFTWARE Apache/2.4.10 (Unix) PHP/5.5.20

I am on Mac OS X Yosemite 10.10.3

Thanks!

图片转代码服务由CSDN问答提供 功能建议

所以我从源代码编译了pdo_pgsql并将扩展名添加到我的php.ini < pre> phpinfo()

 支持PDO 
 
PDO支持
PDO驱动程序 mysql,sqlite,pgsql 
 
pdo_pgsql 
 
PDO启用PostgreSQL的驱动程序
PostgreSQL(libpq)版本9.4.2 
模块版本1.0.2 
   
 
 

但是

  pg_connect(“host = localhost dbname = dbname user = username password = password”)
   
 
 

给出< / p>

 调用未定义的函数pg_connect()
   
 
 

是的,我确实重启了apache。 <前> SERVER_SOFTWARE Apache / 2.4.10(Unix)PHP / 5.5.20

我在Mac OS X Yosemite 10.10.3 < / p>

谢谢!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duan19805 2015-06-04 16:25
    已采纳

    How about make your connection like so:

        try {
            $conn = new PDO('pgsql:host=localhost;port=port-number;dbname=database','db-user','db-pass');
    
            $conn->query("SET NAMES UTF8");
        } catch (PDOException $e) {
            die('Connection failed: ' . $e->getMessage());
        }
    
    点赞 评论

相关推荐 更多相似问题