You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now when Leaf tries to connect to the database mysql_db_1 via \Leaf\Database::initDb(); it issues an error saying could not find driver in /leafs/db/src/Db/Core.php. Going through the stack trace shows that in /leafs/db/src/Db/Core.php it tries to do a connection with the following DSN:
The part mysql_db_1 is the name of the connection instead of the specified driver. The problem seems to come from /leafs/mvc-core/src/Database.php where it does the following:
The way it is currently implemented it is assuming that the name of the database is equal to the driver. This is also what I've seen in most of the examples where only one database is used (name always equals driver / dbtype). I can see that I can work around this by naming my first database mysql but I think that's not how it should be.
I'm using a fresh installation of Leaf in version 3.3.
The text was updated successfully, but these errors were encountered:
@mychidarko Of course you can tie this issue with the multi-db one (issue #9). I was initially thinking about reporting both issues in one ticket. But in my view this here is a bug that affects also non-multi-db-usage while the other issue is rather a lack of functionality that affects only multi-db-usage.
I'm in a project where I need to have multiple MySQL database connections. My setup in the database config looks like this:
With the .env file having this part concerning the database:
Now when Leaf tries to connect to the database
mysql_db_1
via\Leaf\Database::initDb();
it issues an error sayingcould not find driver
in/leafs/db/src/Db/Core.php
. Going through the stack trace shows that in/leafs/db/src/Db/Core.php
it tries to do a connection with the following DSN:The part
mysql_db_1
is the name of the connection instead of the specified driver. The problem seems to come from/leafs/mvc-core/src/Database.php
where it does the following:In my opinion, the line with
'dbtype' => static::$config['default'] ?? 'mysql',
should actually look like this:The way it is currently implemented it is assuming that the name of the database is equal to the driver. This is also what I've seen in most of the examples where only one database is used (name always equals driver / dbtype). I can see that I can work around this by naming my first database
mysql
but I think that's not how it should be.I'm using a fresh installation of Leaf in version 3.3.
The text was updated successfully, but these errors were encountered: