php - Cross Database in ZF2 -


how join 2 tables different databases using zf2? write following query.

select db1.table1.*, db2.table2.* db1.table1 inner join db2.table2 on db2.table2.field1 = db1.table1.field1 

please give example?

i didn't check syntax it's this:

$db = new zend_db_adapter_pdo_mysql(array(     'host'     => '127.0.0.1',     'username' => 'webuser',     'password' => 'xxxxxxxx',     'dbname'   => 'test' )); $select = $db->select()              ->from( array( 'table1' => 'db1.table1' ), array( 'table1.*','table2.*' ) )              ->joininner( array( 'table2' => 'db2.table2' ), 'table2.field1 = table1.field1', array() ); $result = $select->query->fetchall(); var_dump($result); 

edit: $db definition sourced http://framework.zend.com/manual/1.12/en/zend.db.adapter.html


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -