views:

555

answers:

2

I want to join two tables in differenet databases on the same server. Could someone tell me how I could do this in Zend Frameworks Db adapter?

+1  A: 

see:

http://stackoverflow.com/questions/1516359/connecting-to-two-different-databases-with-zend-framework

http://blog.keppens.biz/2009/04/zendapplication-multiple-databases.html

http://blog.ekini.net/2009/03/04/zend-framework-connecting-to-2-databases/

Natrium
hi thanks for the reply...but i have alreday got connection to two dbs and can switch between two seemlessly...but dont know how to contrsuct the sql for a join of tow table sitting in two databases.plz advice me..thanks.
sha
A: 

If the databases are on the same server and your user have access to them both, you can use full path - SELECT database_name.table_name.col_name...

Otherwise there is no chance for you to join them because of the principle. The join is done by SQL server - which would need to login to the other database...

On Oracle there is a feature called DBLink... which offers abbility to link other table/view from different server. Not sure about MySQL.

To make queries using different adapters you can use:

$select1 = new Zend_Db_Select($adapter1);
$select2 = new Zend_Db_Select($adapter2);

But again, you are still limited in things like union of these two... You can't do that because of the very nature of how the database works

Tomáš Fejfar
not sure about the full path, but i guess it should work
Tomáš Fejfar
thx for the reply..but the thing is hw to do with zend....i hv adapters for each connection and by nature i hv to apply the query using one adapter..so hw do i use other db in a seperate adapter...can u give me an example plz?
sha
Edited the answer. Not sure if that's what you're looking for.
Tomáš Fejfar