Web Development Tips and Tricks

Web Development Tips and Tricks

Wednesday, May 30, 2012

Connect to 2 databases at the same time in PHP

if your database user has access to both databases and they are on the same server, you can use one connection and just specify the database you want to work with before the table name. Example:

SELECT column
FROM database.table

Depending on what you need to do, you might be able to do an INSERT INTO and save a bunch of processing time.

INSERT INTO database1.table (column)
SELECT database2.table.column
FROM database2.table
select and insert at same time
fetch from one table and insert in single query

No comments:

Post a Comment