Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Invoking propel:database:create throws a PDO connection error #159

Merged
merged 1 commit into from Jun 11, 2012

Conversation

Projects
None yet
3 participants

At least the MySQL PDO must be connected without the dbname in its dsn because the db being created does not exist yet.

Tested MySQL Server version 5.5.21.

Tero Kaisti The MySQL PDO must be connected without the dbname in its dsn because…
… the db being created does not exist yet.


Tested MySQL Server version 5.5.21.
b4475d2

This pull request passes (merged b4475d2 into bd4c79d).

Owner

willdurand commented Jun 7, 2012

Actually, this is just a trick to be able to access the database server.
We don't use the database name to create, but a database name which should always be defined on the server like mysql for MySQL, or pgsql for PostgreSQL.

The fact is that you can not connect to a non-existing database with PDO in MySQL. You can test it with creating a user with all privileges granted and trying to create a table.

So far I haven't found any obligatory requirements of the dbname usage in dsn parameter. Here's a small thread about the issue http://stackoverflow.com/questions/2583707/can-i-create-a-database-using-pdo-in-php

Other than MySQL drivers might interpret the dsn differently, so maybe there should be added a conditional statement for dbname usage. Otherwise the support for this command should be reconsidered as it won't work as expected.

@willdurand willdurand added a commit that referenced this pull request Jun 11, 2012

@willdurand willdurand Merge pull request #159 from terokaisti/patch-2
Invoking propel:database:create throws a PDO connection error
5a764c6

@willdurand willdurand merged commit 5a764c6 into propelorm:1.1 Jun 11, 2012

Owner

willdurand commented Jun 11, 2012

Let's see. It's probably better anyway. Thanks!

I was thinking we could improve the method by using switch case for driver detection and replace preg with str_replace ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment