How to use multiple MySql database in PHP, MYSQLi & PDO

Here in this tutorial I'm going to explain how you can connect multiple mysql databasees using PHP and how can you query with multiple database connections in PHP.
Here we have single instance with multiple database connections.

If you are going to use MYSQLi with PHP you can create multiple connections like below. Here we have 2 database connections.

Here we are querying with same table names but with different databases.

If you are going to use PDO with PHP then you can create database connections like below.

Here is the way to querying with same table names but with different databases using PDO.

  ...  Read More

Share This: