Welcome Guest, Not a member yet? Register   Sign In
CI can not connect to PostgreSQL database
#1

[eluser]Unknown[/eluser]
Hi!

I'm a new bie of CI Framework. I've read CI document and follow step by step from it. Instead of using MySQL database, I use PostgreSQL.

But I can connect to PostgreSQL database. I don't know why? Could you give me some how to debug CI framework?

I almost used all latest version of software:
CentOS 6.4
Apache 2.4.4
PHP 5.4.13
PostgreSQL 9.2.3

Bellow is my database.php file:
---------------------------------
/*
| -------------------------------------------------------------------
| TEST ENVIROMENT
| -------------------------------------------------------------------
*/
$db['test']['hostname'] = 'localhost';
$db['test']['username'] = 'postgres';
$db['test']['password'] = 'P@ssw0rd';
$db['test']['database'] = 'helloworld';
$db['test']['dbdriver'] = 'postgre';
$db['test']['port'] = '5432';
$db['test']['dbprefix'] = '';
$db['test']['pconnect'] = TRUE;
$db['test']['db_debug'] = FALSE;
$db['test']['cache_on'] = FALSE;
$db['test']['cachedir'] = '';
$db['test']['char_set'] = 'utf8';
$db['test']['dbcollat'] = 'utf8_general_ci';
$db['test']['swap_pre'] = '';
$db['test']['autoinit'] = TRUE;
$db['test']['stricton'] = FALSE;
/*
| -------------------------------------------------------------------
| DEBUG PGSQL CONNECTION
| -------------------------------------------------------------------
| http://ellislab.com/forums/viewthread/207916/
|
*/
echo '<pre>';
print_r($db['test']);
echo '</pre>';

echo 'Trying to connect to database: ' .$db['test']['database'];
$host = $db['test']['hostname'];
$user = $db['test']['username'];
$pass = $db['test']['password'];
$port = $db['test']['port'];
$db = $db['test']['database'];

$conn_str = "host=$host port=$port dbname=$db user=$user password=$pass";
echo '<br />Connection string: ' . $conn_str;
$dbh = pg_connect($conn_str)
or die ('<br />Could not connect to server!' . pg_last_error($dbh));

echo '<br /> Connected OK!' ;
die( '<br />File: ' .__FILE__ . '--&gt; Line: ' .__LINE__);
//----------------------------

The tutorial I followed:
http://ellislab.com/codeigniter/user-gui...ction.html


Messages In This Thread
CI can not connect to PostgreSQL database - by El Forum - 03-19-2013, 09:35 PM
CI can not connect to PostgreSQL database - by El Forum - 03-20-2013, 04:38 AM
CI can not connect to PostgreSQL database - by El Forum - 03-20-2013, 08:06 AM
CI can not connect to PostgreSQL database - by El Forum - 03-20-2013, 08:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB