Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/06/2014, 10:43
Avatar de arcanisgk122
arcanisgk122
 
Fecha de Ingreso: junio-2010
Mensajes: 755
Antigüedad: 13 años, 11 meses
Puntos: 28
Respuesta: Problemas al seleccionar mas de una tabla

algo como :

Código PHP:
Ver original
  1. //$db is an instance of Zend_Db_Adapter_Abstract
  2. $select = $db->select();
  3. $select->from(array('p' => 'person'), array('person_id', 'name', 'dob'))
  4.        ->join(array('pa' => 'Person_Address'), 'pa.person_id = p.person_id', array())
  5.        ->join(array('a' => 'Address'), 'a.address_id = pa.address_id', array('address_id', 'street', 'city', 'state', 'country'));
  6.  
  7. $db->fetchRow($select);
  8.  
  9. echo $select; //prints SQL

No te sirve??


Código PHP:
Ver original
  1. <?php
  2.  
  3. // Given that $dbAdapter is an instance of Zend\Db\Adapter\Adapter
  4.  
  5. use Zend\Db\Sql\Select();
  6. use Zend\Db\ResultSet\ResultSet();
  7.  
  8. $select = new Select();
  9. $select->from('album')
  10.    ->columns(array('album.*', 'a_name' => 'artist.name'))
  11.    ->join('artist', 'album.artist_id' = 'artist.id');
  12.  
  13. $statement = $dbAdapter->createStatement();
  14. $select->prepareStatement($dbAdapter, $statement);
  15. $driverResult = $statment->execute();
  16.  
  17. $resultset = new ResultSet();
  18. $resultset->setDataSource($driverResult);
  19.  
  20. foreach ($resultset as $row) {
  21.         // $row is an ArrayObject
  22. }
__________________
Cooler Master Gladiator 600 - AMD PHENOM II X4 955 @ 3.5GHZ
GA-MA78GM-US2H - Super Talent 800 2GB x 2 Dual, (Unganged)
PSU Cooler Master eXtreme Power Plus 500W - Saphire R7-260OC-2GB