16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CakePHPでPostgreSQLを使う

Last updated at Posted at 2013-11-20

CakePHPでPostgreSQLを使う場合のdatabase.phpはこういう感じ。

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

MySQLの場合チュートリアル通りにやれば問題無いが、

PostgreSQLではportとschemaを指定しないと以下のようなエラーになる。

Error: Table posts for model Post was not found in datasource default.

また、Windowsのローカルで開発を行う場合、PostgreSQLにつなぐためのDLLが必要になる。

設定はできているのに繋がらない。もしくは、ピュアなPHPプログラムからはPostgreSQLに接続できるのに、CakePHPからは接続出来ない場合は、以下のDLLが壊れていないか確認すること。

Error: Database connection "Postgres" is missing, or could not be created.
  • php_pdo_pgsql.dll
  • php_pgsql.dll

参考:
http://andante0727.blog81.fc2.com/blog-entry-151.html

16
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?