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!

  • 写回答

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());
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 visionmaster启动失败,提示为“机器不满足授权而被禁用”
  • ¥50 用logisim设计16位单时钟周期cpu
  • ¥15 IDEA中圈复杂度如何具体设置
  • ¥50 labview采集不了数据
  • ¥15 请上面代码做什么处理或什么混淆
  • ¥15 英雄联盟自定义房间置顶
  • ¥15 W5500网线插上无反应
  • ¥15 如何用字典的Key,显示在WPF的xaml中
  • ¥15 weautomate读取Excel表格信息然后填写到网页一直报错,如何解决?
  • ¥15 C#如何在Webview2中获取网页验证码