XREAでCodeIgniterにPostgreSQL接続
XREAのサーバを使っていますが、CodeIgniterからPostgreSQL接続しようとすると、CIが次のようなエラーメッセージを吐いて失敗してしまいます。
An Error Was Encountered
Unable to connect to your database server using the provided settings.
接続してる部分のソースをチェックしてみる。
system/database/drivers/postgre/postgre_driver.php を開いて「@pg_pconnect」→「pg_pconnect」に変えて実行すると、
Message: pg_pconnect() [function.pg-pconnect]: Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?
やっぱり接続時に問題がある模様。
サポートページを調べていたら参考になる記事が見つかりました。
・PGSQLへの接続失敗 - XREA&CORE SUPPORT BOARD
つまり、TCP/IP接続でなくソケット経由で接続をしてるので、host、portは指定してはいけないとのこと。
postgre_driver.phpを修正してみます。
return @pg_pconnect("host=".$this->hostname.$port." dbname=".$this->database." user=".$this->username." password=".$this->password);
↓
return @pg_pconnect($port." dbname=".$this->database." user=".$this->username." password=".$this->password);
接続できました!
ほんとはdatabase.phpのhostname設定を見てhostを指定するかしないか切り替えれば良いと思いますが、まあ取り急ぎ対応です。
- 3キャリア別にフォーム入力モードを切り替えるカスタムヘルパー - 2009年4月03日
- オブジェクトのシリアル化についてのメモ - 2009年3月12日
- askeet 4日目 - 2009年2月24日
- symfonyでPDO接続をする - 2009年2月18日
- PEAR::HTTP_Requestでタイムアウト時間を指定する - 2008年8月23日
トラックバック(0)
このブログ記事を参照しているブログ一覧: XREAでCodeIgniterにPostgreSQL接続
このブログ記事に対するトラックバックURL: http://blog.knockoutmarch.com/mt3/mt-tb.cgi/82
コメントする