Hi Andrew,
thanks for your answer. With your modified code i can connect to databases
with a '-' in the name.
Are you a part of the Zend development team? If not you should open an
improvement issue within the issue tracker.
Regards,
Marcus
Andrew Bidochko-2 wrote:
>
> Hello shockshell,
>
> I was facing the same problem connecting to a data base with a space
> in its name using Zend Framework PDO (the latest and greatest v
> 1.7.0).
>
> So what I did first, I setup a simple script to connect to a MSSQL
> database using native PDO methods... and it worked:
>
> <code>
> try {
> $db = new PDO('mssql:host=mssqlhost;[dbname=DB name with a space]',
> 'user', 'secret');
> echo "connected!\n";
> } catch (PDOException $e) {
> echo "Failed to get DB handle: " . $e->getMessage() . "\n";
> exit;
> }
> </code>
>
> That experiment gave me an idea that something is wrong with a Zend
> MSSQL connection implementation.
> I noticed that a database name should be placed in [...] in order to
> do a proper connection to a database with a space in its name.
> I modified a _dsn() method in a Zend_Db_Adapter_Pdo_Mssql class to
> create a proper $dsn value:
>
> <code>
> ...
> // use all remaining parts in the DSN
> foreach ($dsn as $key => $val) {
> // put database name in [], to allow white space in a database
> name
> if ($key == 'dbname') {
> $dsn[$key] = "[$key=$val]";
> } else {
> $dsn[$key] = "$key=$val";
> }
> }
> ...
> </code>
>
> After that change a database connection has been sucesfully
> established!
>
> Marcus, would you like to verify my fix on a database containing '-'
> in its name. Thanks!
>
> --
> Best regards,
> Andrew Bidochko
> Software Engineer/Architect
> Mashup Technologies
> http://mashuptechnologies.com
>
>
>
>
--
View this message in context:
http://www.nabble.com/mssql-Database-Connection-Problem-tp20445271p20840794.html
Sent from the Zend Framework mailing list archive at Nabble.com.