I have 2 databases (db1,db2)in mysqli with different users and passwords, I try to connect but it failed ,
$this->db = mysqli_connect(self::DB_SERVER, self::DB_USER, self::DB_PASSWORD,self::DB);
I did in the query:
select*from db2.table
but gave an error , the example above success in local when there is no user and password for databases. Please help
If you have different usernames and passwords on the databases, I don't think a single connection can go across that. So you would at the very least have to change them to use the same mysql user.
OR, if you don't need to access from a single connection use something like this:
https://github.com/thephpeffect/ConnectionManager
db("default", new mysqli(self::DB_SERVER, self::DB_USER1, self::DB_PASSWORD1,self::DB1));
db("db2", new mysqli(self::DB_SERVER, self::DB_USER2, self::DB_PASSWORD2,self::DB2));
$result = db("db2")->query("select*from db2.table");