ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_multidatabase:connections

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
v5:userguide:learn_multidatabase:connections [2016/03/19 02:30] – created mnewnhamv5:userguide:learn_multidatabase:connections [2017/04/18 11:07] (current) – Fix broken link dregad
Line 1: Line 1:
 +<-  ^ v5:userguide:userguide_index|List Of Tutorials ^ v5:userguide:learn_multidatabase:transactions|Handling Transactions ->
 +~~NOTOC~~
 +====== Connecting to Multiple Databases ======
 +ADOdb can control unlimited independent connections because each connection is controlled completely separately. 
  
-===== Connecting to Multiple Databases ===== +The connections can be multiple connections to the any type of database.
-In this example we maintain connections to 2 databases at the same time. The transactional status of each database is managed independantly, but we can ensure that both databases remain synchronized by checking the transactional status of both connections before committing changes to both. +
 <code php> <code php>
 +/*
 +* Only one instance of common code need to be loaded
 +*/
 +include 'adodb/adodb.inc.php'; 
  
-include 'adodb.inc.php';  # load code common to ADOdb +/* 
- +* Establish connection to 2 mysql databases 
-$conn1 = adoNewConnection('mysql');  # create a mysql connection +*/ 
-$conn2 = adoNewConnection('oracle');  # create a oracle connection +$conn1 = newAdoConnection('mysqli'); 
- +$conn2 = newAdoConnection('mysqli');
-$conn1->connect($server, $userid, $password, $database); +
-$conn2->connect(false, $ora_userid, $ora_pwd, $oraname); +
- +
-$conn1->Execute('insert ...'); +
-$conn2->Execute('update ...');+
  
 +/*
 +* Add an additional connection to oracle
 +*/
 +$conn3 = newAdoConnection('oci8');
 </code> </code>
- 
  
  
v5/userguide/learn_multidatabase/connections.1458351049.txt.gz · Last modified: 2017/04/21 11:40 (external edit)