Re: [fw-general] pdo_pgsql connection info string error

2008-12-13 Thread Justin Verweel

till wrote:

Is space the only char that's affected by this?

Till
  

I think so, but I'm not sure.
I have tested some other SQL special chars in the username, like ', " 
and % and they are working fine.







[fw-general] Re: pdo_pgsql connection info string error

2008-12-12 Thread Justin Verweel

Hi A.J.

I escape the whitespace with a backslash
$aParams = array( 'host'=> 'localhost',
   'username'=>'jan\ willem',
   'password'=> 'bsouser',   
   'dbname'=> 'bso' );

$oDb = Zend_Db::factory( 'pdo_pgsql', $aParams );

$oDb->prepare( 'SELECT 1' )->execute();

Thanks for the zf-issue. I must have missed it, when I searched the 
issue list today.


Justin


a...@ajbrown.org wrote:

Hi Justin,

How did you escape the whitespace?  did you use square brackets?

- A.J. Brown

  




[fw-general] pdo_pgsql connection info string error

2008-12-12 Thread Justin Verweel

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