douzhunlan5930 2012-09-12 17:14
浏览 59
已采纳

Heroku Postgres从localhost PHP应用程序连接

Is there anyway to connect to the Heroku postgres (Free) db instance from a locally running PHP application. I am able to get pgAdminIII successfully connected, but no luck through application connection string connecting to the same Db?

Connection

$dbconn = pg_connect("host=xxxxxx.compute-1.amazonaws.com port=5432 dbname=xxxxxxx user=xxxxxx password=xxxxxx sslmode=require options='--client_encoding=UTF8'");

Error Thrown from PHP Code:

 Warning: pg_connect(): Unable to connect to PostgreSQL server: sslmode value "require" invalid when SSL support is not compiled in in 

I found the following on Heroku's site but I am hoping someone can clarify whether I'm dealing with a postgres php issue (running PHP on Apache, PHP 5.3 on Mac OS X Lion 10.7.4) or if this is just an environment restriction as indicated in Heroku's following statement:

How do I connect to Heroku Postgres? Databases on Heroku Postgres accept standard PostgreSQL connections. Connections can be made from PostgreSQL client applications (such as psql, or PGAdmin), Application Frameworks (such as Ruby-on-Rails or Django), or any other libpq compatible client, from anywhere over SSL.

Shared databases however, can only be connected to from applications running on Heroku.

Can someone also explain why pgAdminIII is able to connect but my application cannont?

Thank you.

Further Findings: PHPINFO->

  • OpenSSL support enabled
  • OpenSSL Library Version OpenSSL 0.9.8r 8 Feb 2011
  • OpenSSL Header Version OpenSSL 0.9.8r 8 Feb 2011

  • PostgreSQL Support enabled

  • PostgreSQL(libpq) Version 8.2.23
  • SSL support disabled
  • 写回答

1条回答 默认 最新

  • douyue1481 2012-09-13 21:29
    关注

    So I spoke with a representative at Heroku. They confirmed for me that it does not require any specific tier of account to connect to a Heroku Postgres database, the only stipulation is that the connection uses ssl when connecting remotely. So my issue is the result of pgsql not having ssl support in my build of php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?