473,657 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple database access Bug in adoDB and It's Solution

Fixing Multiple Database bug in adoDB

popular data access layer for php, adoDB can support multiple databases
from different provider at time, but not from same provider. what I
mean is if you instantiate two adoDB connection like this

$db1 = &NewAdoConnecti on ("mysql");
$db1 = &NewAdoConnecti on ("oracle");

then you can run queries simultaneously from these connections. but if
you want to access two database from same provider like this

$db1 = &NewAdoConnecti on ("mysql");
$db1 = &NewAdoConnecti on ("mysql");
$db1->PConnect(login info_for_first_ database)
$db2->PConnect(login info_for_second _database)

then only last action will remain active and if you use
$db1->execute(), it will actually works on second database. if you want
to access any table from first database, it will generate an error. I
think this is an internal bug in adoDB.

How to fix this bug?

if you open adodb-mysql.inc.php and goto function _connect() you will
find this line at the end

1. if ($argDatabasena me) return $this->SelectDB($argD atabasename);

now goto SelectDB function and see what it contains actually.

// returns true or false
function SelectDB($dbNam e)
{
$this->databaseName = $dbName;
if ($this->_connectionI D) {
return @mysql_select_d b($dbName,$this->_connectionID) ;
}
else return false;
}

so it basically returns a boolean value, mysql connection link is
stored in $this->_connectionI D variable. Now modify this code like this

1. add this line at the declaration section of adodb-mysql.inc.php

var $__db = array();

2. modify the SelectDB function like this

// returns true or false
function SelectDB($dbNam e)
{
$this->databaseName = $dbName;
if ($this->_connectionI D) {
@mysql_select_d b($dbName,$this->_connectionID) ;
$this->__db[$this->_connectionI D] = $dbName;
return $this->_connectionI D;
}
else return false;
}

3. Now open the _query function and modify it like this

// returns queryID or false
function _query($sql,$in putarr)
{
//global $ADODB_COUNTREC S;
//if($ADODB_COUNT RECS)
$this->SelectDB($th is->__db[$this->_connectionI D]);
return mysql_query($sq l, $this->_connectionID) ;
//else return @mysql_unbuffer ed_query($sql,$ this->_connectionID) ;
// requires PHP >= 4.0.6
}

That's it!!, now your adoDB supports multiple databases from same
provider.

Thanks
Hasin Hayder
http ://groups.yahoo.co m/group.phpexpert s

Mar 27 '06 #1
0 3245

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1744
by: QT | last post by:
Dear Sirs, I could not understand vb.net database connection statements for access.mdb. I was using following procedures with vb 6 without problem. But I can not find same solution for vb.net For example I can not get any data with; adoPrimaryRS!Gurup. I try to find somehing on msnds, but no result. What should I do? where can I find solutions
4
16753
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from customers; I can execute each statement individually but get the 'you have an error in
3
10168
by: KemperR | last post by:
Hello Experts outhere, may be someone can tell me whats going wrong with my ADOX trial. I have an Access 2002 database with some tables and queries (views) The code listed below works well up to the point where I want to add the new view to the views collection. I get Runtime error 3001 which is telling me "Arguments are of wrong type,are out of acceptable range or conflict with one another"
12
20902
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database contains the paths to the pictures. The database consists of two tables: TABLE DATA ID Name LastName
7
18974
by: Wilfried Mestdagh | last post by:
Hi, I wants to to something really simple, but dont succedd in C# :( I'm using 2005 beta version with .net 2 beta. I wants to connect ot an Access database and do a query, and then in the dataset a First() , Next() until Eof(); Also I want to access fields in the dataset (of course), but I cannot find anything like 'fieldbyname' or something.. how access fiels ?
16
5717
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and got a nudge in the right direction from Mr. Kreft. I promised to provide details once working, so here it is. The code is shown below. My next step is to build this technique into my application. I'm hoping for substantial performance gain. ...
4
3680
by: musicloverlch | last post by:
I have a table with multiple records in it. I am being forced to combine multiple records into one record in order to be uploaded to a website, and I only get one record per client. How can I systematically combine multiple records into 1? The table looks like this Client ID Service Status 1 Doc Pending 1 Test Pending
4
1417
by: Samuel | last post by:
Hi, I am looking for a library that takes an XML file that specifies a table structure, and generates the CREATE/DROP/ALTER SQL statements to create the tables in the database. In particular, I am trying to port a PHP application that currently uses the AdoDB XML schema:
0
1390
by: BobbieMorrow | last post by:
I have just started working with MySQL and converting one of our company's larger database. What I want to do is send a variable to the stored procedure and return another variable to access for testing. I keep getting the error, expected 2 got 1 when I execute the below code: Dim ds As ADODB.Recordset Dim Comm As ADODB.Command Dim SQL As String Dim OConn As Connection Dim Part As String Dim Filling As String Dim myPam As...
0
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.