catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

Database name in select method #922

Closed lcsqlpete closed 3 years ago

lcsqlpete commented 4 years ago

My application uses two mySQL databases on the same db host with 90% of the queries coming from one database which I name in the connect method and 10% from the other. For the 10%, I would like to specify the database name as part of the table parameter of the select method, e.g mydb.mytable, so I don't have to open a second connection to the same host but I am getting error "Uncaught InvalidArgumentException: Incorrect table name".

Am I doing something wrong or does medoo not allow this? If the latter, is there some other way to do this without opening a second connection.

catfan commented 4 years ago

In some of case, switching database will be connecting different host or different configuration. It's need to create a new connection for that.

You can create a connection class to manage all the database connections in project, and switch it what you want.

lcsqlpete commented 4 years ago

Both databases are on exactly the same connection, same host, same user, same password so opening a second connection is not necessary.

lucashtc commented 1 year ago

This is a feature that is needed.

JuneTwooo commented 1 year ago

Clearly we need it