Home » Database » DB » Bug #1470
Query across multiple tables does not return proper results
Details
| Submitted | 2004-05-22 20:40 UTC |
|---|---|
| From | onghl at singnet dot com dot sg |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 4.3.6 |
| OS | Windows |
| Roadmaps | (Not assigned) |
Comments
[2004-05-22 20:40 UTC] onghl at singnet dot com dot sg
Description:
------------
Hi,
I was using the DB packages for retrieving data across more than 1 table. I notice that the fetchrow() function with the DB_FETCHMODE_OBJECT or DB_FETCHMODE_ASSOC parameter overwrites the data on previous linked table which had the same field name.
e.g
Assume that I had 2 table namely Manager & Client with the following fields. Notice that the fieldname (ManagerID, Name & Age) are same across the 2 table:
[Manager] ManagerID, Name, Dept, Age
[Client] ManagerID, ClientID, Name, Age
When I use the following query using limitQuery() and use fetchrow() with DB_FETCHMODE_OBJECT or DB_FETCHMODE_ASSOC:
Select * from Manager,Client where Manager.ManagerID = Client.ManagerID
The return results are
([ManagerID] =>1
[Name]=>ClientName
[Dept]=>Dept
[Age]=>ClientAge
[ClientID]=>ClientID)
I would actually expect the return result to be
([Manager.ManagerID] =>1
[Manager.Name]=>ManagerName
[Manager.Dept]=>ManagerDept
[Manager.Age]=>ManagerAge
[Client.ManagerID]=>ClientID)
[Client.ClientID]=>ClientID)
[Client.Name]=>ClientName)
[Client.Age]=>ClientAge)
DB_FETCHMODE_ORDERED return the results correctly
The version that I'm using is 1.6.4
Thanks and Regards
Ong
Expected result:
----------------
I would actually expect the return result to be
([Manager.ManagerID] =>1
[Manager.Name]=>ManagerName
[Manager.Dept]=>ManagerDept
[Manager.Age]=>ManagerAge
[Client.ManagerID]=>ClientID)
[Client.ClientID]=>ClientID)
[Client.Name]=>ClientName)
[Client.Age]=>ClientAge)
Actual result:
--------------
The return results are
([ManagerID] =>1
[Name]=>ClientName
[Dept]=>Dept
[Age]=>ClientAge
[ClientID]=>ClientID)