Welcome Guest, Not a member yet? Register   Sign In
PostgreSQL - catching errors without db_debug?
#1

[eluser]smilie[/eluser]
Hi all,

I am having following 'issue';
my DB config:

Code:
$db['group']['hostname'] = 'someHost';
$db['group']['username'] = 'someUser';
$db['group']['password'] = 'somePass';
$db['group']['database'] = 'someDB';
$db['group']['dbdriver'] = 'postgre';
$db['group']['dbprefix'] = '';
$db['group']['pconnect'] = TRUE;
$db['group']['db_debug'] = FALSE;
$db['group']['cache_on'] = FALSE;
$db['group']['cachedir'] = '';
$db['group']['char_set'] = 'utf8';
$db['group']['dbcollat'] = 'utf8_general_ci';
$db['group']['swap_pre'] = '';
$db['group']['autoinit'] = TRUE;
$db['group']['stricton'] = FALSE;
$db['group']['port']    = '5432';

Problem is that my IP is _not_ allowed to connect to this database at the moment.
However, when I execute this piece of code:

Code:
$ffDB = $this->ci->load->database('group',TRUE);
$someData = array(
    'data'  => 'content'
);

$do = $ffDB->insert('table',$someData);
var_dump($do);

above var_dump return bool(true);
while I would expect: bool(false) - hence there is _no_ DB connection!

If I would set in database.php db_debug = TRUE then I would receive error that no connection could be made, but then my whole script stops and I receive CI standard error report which is not what I want / need.

If I set (config.php) logging on I do see:
ERROR - 2012-10-24 10:29:00 --> Severity: Warning --> pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "someUser" /cipath/database/drivers/postgre/postgre_driver.php 86
ERROR - 2012-10-24 10:29:00 --> Unable to connect to the database

But - I would like to catch this in PHP code - and not to be escaped to CI error pages...

Any ideas? My MySQL connections are behaving as expected btw.

Thanks!

Cheers,
Smilie




Theme © iAndrew 2016 - Forum software by © MyBB