Hello all,

I'm using Zend_Db to connect to a postgresql database server, works fine until today when I added a new login role with a whitespace in it's rolename. When I try to connect to the database with that rolename, an exception tells me there is something wrong with the rolename.

I tried to connect to the database with that rolename in PgAdmin III and that works fine, so postgresql accepts a rolename with a whitespace.

Some code I used to test:

// With my own rolename it works fine
$aParams = array(     'host'    =>     'localhost',
                                'username'    =>    'justin',
'password' => '****', 'dbname' => 'test' );
$oDb = Zend_Db::factory( 'pdo_pgsql', $aParams );
$oDb->prepare( 'SELECT 1' )->execute();


// But this fails
$aParams = array(     'host'    =>     'localhost',
                                'username'    =>    'jan willem',
'password' => '****', 'dbname' => 'test' );
$oDb = Zend_Db::factory( 'pdo_pgsql', $aParams );
$oDb->prepare( 'SELECT 1' )->execute();

*Fatal error*: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[08006] [7] missing "=" after "willem" in connection info string' in /usr/local/ZendFramework/1.7.0/library/Zend/Db/Adapter/Pdo/Abstract.php:143 Stack trace: #0 /usr/local/ZendFramework/1.7.0/library/Zend/Db/Adapter/Pdo/Abstract.php(167): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 /home/justin/domains/dev.intern.basisscholenonline.nl/public_html/postgres.php(19): Zend_Db_Adapter_Pdo_Abstract->prepare('SELECT 1') #2 {main} thrown in */usr/local/ZendFramework/1.7.0/library/Zend/Db/Adapter/Pdo/Abstract.php* on line *143*

I figured out that escaping the whitespace fixes this problem, but shouldn't this been done by Zend_Db instead of myself?

Thnx and greetings.

Justin Verweel

p.s. Used ZF version is 1.7.1




Reply via email to