Advertisement
Guest User

Untitled

a guest
Feb 29th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1.     public function init()
  2.     {
  3.         $games = new Application_Model_DbTable_Game();
  4.    
  5.         // first construct the subquery/join for the IN clause
  6.         // SELECT idGameType FROM GameType HERE nameGameType = 'Xbox'    
  7.         $subselect = $games->select()
  8.                              ->from('GameType', array('idGameType'))
  9.                              ->where('nameGameType = ?', 'Xbox');
  10.        
  11.         // construct the primary select
  12.         // SELECT titleGame FROM Game WHERE idGameType IN (subquery)
  13.         $select = $games->select()
  14.                           ->setIntegrityCheck(false) // allows us to select from another table
  15.                           ->from($games, array('titleGame'))
  16.                           ->where('idGameType IN (?)', $subselect);
  17.                          
  18.         $this->view->games = $select->query()->fetchAll();
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement