PHP Classes

multiple databases

Recommend this page to a friend!

      CRDB  >  All threads  >  multiple databases  >  (Un) Subscribe thread alerts  
Subject:multiple databases
Summary:use multiple databases
Messages:2
Author:Proxing
Date:2010-12-22 05:12:33
Update:2010-12-22 16:25:41
 

 


  1. multiple databases   Reply   Report abuse  
Picture of Proxing Proxing - 2010-12-22 05:12:33
Hello,

I would like to use this class in my Website, but there is a problem.
The Page needs Data from 5 databases and i don't know how with this class.

Is it possible without closing the Connection?

  2. Re: multiple databases   Reply   Report abuse  
Picture of Sandeep.C.R Sandeep.C.R - 2010-12-22 16:25:41 - In reply to message 1 from Proxing
Hi,

Thank you for using this class,


Now, regarding your query, If you have to access data from different databases, it can be done using the _set_link function to use a different database link.

For Example;

<?php
include 'crdb.php';

// note the fourth paramenter, as it is required so that the function
// returns a new link regardless of identical parameters.

$link_1 = mysql_connect('localhost','root','',true);
$link_2 = mysql_connect('localhost','root','',true);

mysql_select_db('database_1',$link_1);
mysql_select_db('database_2',$link_2);


$cr1=new crdb($link_1);

echo $cr1->database_1_table(1)->name;

$cr1->_set_link($link_2);

echo $cr1->database_2_table(1)->name;

?>

If this is not your requirement, please let me know more details about what you are trying to accomplish.

NOTE: Please download the class file as I have made a bug fix regarding this requirement.


Thanks,
Sandeep.