ezSQL / ezsql

PHP class to make interacting with a database ridiculusly easy
http://ezsql.github.io/ezsql
GNU Lesser General Public License v3.0
866 stars 291 forks source link

Can no longer connect to two databases at the same time #179

Closed peterblay closed 4 years ago

peterblay commented 4 years ago

$db = Database::initialize('mysqli', ['ezsql_user', 'ezsql_password123', 'ezsql_database']); $db1 = Database::initialize('mysqli', ['ezsql_user1', 'ezsql_password1234', 'ezsql_database1']);

Referencing either $db or $db1 only returns results from the first connection ($db).

In previous versions 2 / 3, you were able to connect to multple databses this way. I cannot see any documentation referring to multuple connections in version 4.0.

peterblay commented 4 years ago

I have, by trial and error worked a solution. I’m unsure if it is the deemed correct, but it seems to work.

// FIRST CONNECTION use ezsql\Database; $db1 = Database::initialize('mysqli', ['ezsql_user', 'ezsql_password1', 'ezsql_database']);

// SECOND CONNECTION use ezsql\Config; use ezsql\Database\ez_mysqli; $setting = new Config('mysqli', ['mysqli', ['ezsql_user1', 'ezsql_password2', 'ezsql_database1']); $db2= new ez_mysqli($setting);

TheTechsTech commented 4 years ago

Yes, that is the correct way, it's the same issue, my over site, and solution raised in https://github.com/ezSQL/ezsql/issues/176