连接cakephp 2.0和PostgreSQL [英] Connecting cakephp 2.0 with PostgreSQL

查看:157
本文介绍了连接cakephp 2.0和PostgreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cakephp 2.0和wamp服务器。我已经启用了pdo的postgres在PHP和我试图连接到Postgres。但是它仍然说,有一个错误。我的登录名和密码也被双重确认。



下面是database.php文件的代码:

  public $ default = array(
'datasource'=>'Database / Postgres',
'persistent'=> false,
'host'= >'localhost',
'port'=>'5432',
'login'=>'postgres',
'password'=>'password',
'database'=>'Test',
'schema'=>'',
'prefix'=>'',
'encoding'=&
);

我甚至尝试过:

 
public $ default = array(
'datasource'=>'Database / Postgres',
'persistent'=> false,
'host'=>'localhost' ,
'port'=>'5432',
'login'=>'postgres',
'password'=>'password',
'database'=> Test',
'schema'=>'public',
'prefix'=>'',
'encoding'=>''
);

我的pga_hba.config文件是:

 
TYPE DATABASE USER CIDR-ADDRESS METHOD

#IPv4本地连接:
主机全部127.0.0.1/32 md5
#IPv6本地连接:
主机all all :: 1/128 md5

在C:\wamp\bin\php\php5.3.9\ext



我有两个:

 
php_pdo_pgsql.dll
php_pdo_sqlite.dll

我的配置Postgres配置文件是:

 
listen_addresses ='*'#what IP听地址;
#以逗号分隔的地址列表;
#默认为'localhost','*'= all
#更改需要重新启动
port = 5432#(更改要求重新启动)
max_connections = 100#重新启动)
#注意:增加max_connections每
#连接槽大约400字节的共享内存,加锁空间(见max_locks_per_transaction)。
#superuser_reserved_connections = 3#(更改需要重新启动)
#unix_socket_directory =''#(更改需要重新启动)
#unix_socket_group =''(更改需要重新启动)
#unix_socket_permissions = 0777#以0开始使用八进制符号
#(更改要求重新启动)
#bonjour_name =''默认为计算机名称
#(更改要求重新启动)

我检查php信息,我仍然发现pgsql不在那里。我使用wamp服务器。

 
[PostgresSQL]
;允许或阻止持久链接。
; http://php.net/pgsql.allow-persistent
pgsql.allow_persistent = On

;总是用pg_pconnect()检测破坏的持久链接。
;自动复位功能需要一些开销。
; http://php.net/pgsql.auto-reset-persistent
pgsql.auto_reset_persistent = Off

;持续链接的最大数量。 -1表示没有限制。
; http://php.net/pgsql.max-persistent
pgsql.max_persistent = -1

;最大链接数(持久+非持久)。 -1表示没有限制。
; http://php.net/pgsql.max-links
pgsql.max_links = -1

;忽略PostgreSQL后端通知消息或不。
;通知消息记录需要一些开销。
; http://php.net/pgsql.ignore-notice
pgsql.ignore_notice = 0

;日志PostgreSQL后端Noitce消息或不。
;除非pgsql.ignore_notice = 0,否则模块不能记录通知消息。
; http://php.net/pgsql.log-notice
pgsql.log_notice = 0

我已经在我的php.ini文件:

 
extension = php_pdo_pgsql.dll
extension = php_pdo_sqlite.dll
extension = php_pgsql.dll


解决方案

我找到了我的问题的答案这家伙非常有用



http:// tutology .net / category / mysql / install-postgresql-and-phppgadmin-windows-wamp



基本上我从wamp\bin\ php\phpX.XX到wamp\bin\apache\ApacheX.X.XX\bin


I am using cakephp 2.0 and a wamp server. I have enabled the pdo of postgres in the php and i tried connecting to Postgres. However it still says that there is an error. My login and password is also double confirmed.

Below is codes for the database.php file:

public $default = array(
  'datasource' => 'Database/Postgres',
  'persistent' => false,
  'host' => 'localhost',
  'port' => '5432',
  'login' => 'postgres',
  'password' => 'password',
  'database' => 'Test',
  'schema' => '',
  'prefix' => '',
  'encoding' => ''
 );

I even tried this:

public $default = array(
    'datasource' => 'Database/Postgres',
    'persistent' => false,
    'host' => 'localhost',
    'port' => '5432',
    'login' => 'postgres',
    'password' => 'password',
    'database' => 'Test',
    'schema' => 'public',
    'prefix' => '',
    'encoding' => ''
  );

My pga_hba.config file is:

 TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

In the C:\wamp\bin\php\php5.3.9\ext

I have both:

php_pdo_pgsql.dll
php_pdo_sqlite.dll

My config Postgres config file is :

listen_addresses = '*'      # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost', '*' = all
                    # (change requires restart)
port = 5432             # (change requires restart)
max_connections = 100           # (change requires restart)
# Note:  Increasing max_connections costs ~400 bytes of shared memory per 
# connection slot, plus lock space (see max_locks_per_transaction).
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directory = ''     # (change requires restart)
#unix_socket_group = ''         # (change requires restart)
#unix_socket_permissions = 0777     # begin with 0 to use octal notation
                    # (change requires restart)
#bonjour_name = ''          # defaults to the computer name
                    # (change requires restart)

I check php info and I still found that that the pgsql was not there. I am using wamp server.

[PostgresSQL]
; Allow or prevent persistent links.
; http://php.net/pgsql.allow-persistent
pgsql.allow_persistent = On

; Detect broken persistent links always with pg_pconnect().
; Auto reset feature requires a little overheads.
; http://php.net/pgsql.auto-reset-persistent
pgsql.auto_reset_persistent = Off

; Maximum number of persistent links.  -1 means no limit.
; http://php.net/pgsql.max-persistent
pgsql.max_persistent = -1

; Maximum number of links (persistent+non persistent).  -1 means no limit.
; http://php.net/pgsql.max-links
pgsql.max_links = -1

; Ignore PostgreSQL backends Notice message or not.
; Notice message logging require a little overheads.
; http://php.net/pgsql.ignore-notice
pgsql.ignore_notice = 0

; Log PostgreSQL backends Noitce message or not.
; Unless pgsql.ignore_notice=0, module cannot log notice message.
; http://php.net/pgsql.log-notice
pgsql.log_notice = 0

I already did this in my php.ini file:

extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll

解决方案

I have found the answer for my problem This guy is very useful

http://tutology.net/category/mysql/install-postgresql-and-phppgadmin-windows-wamp

Basically i Copied libpq.dll from wamp\bin\php\phpX.X.X to wamp\bin\apache\ApacheX.X.XX\bin

这篇关于连接cakephp 2.0和PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆