Zend Framework Db Select Join table help

Posted by tester2001 on Stack Overflow See other posts from Stack Overflow or by tester2001
Published on 2009-08-13T05:07:14Z Indexed on 2010/04/22 20:03 UTC
Read the original article Hit count: 222

Filed under:
|
|
|
|

I have this query:


SELECT g.title, g.asin, g.platform_id, r.rank
    	FROM games g
    	INNER JOIN ranks r ON ( g.id = r.game_id )
    	ORDER BY r.rank DESC
    	LIMIT 5`

Now, this is my JOIN using Zend_Db_Select but it gives me array error


$query = $this->select();
    	$query->from(array('g' => 'games'), array());
    	$query->join(array('r' => 'ranks'), 'g.id = r.game_id', array('g.title', 'g.asin', 'g.platform_id', 'r.rank'));
    	$query->order('r.rank DESC');
    	$query->limit($top);
    	$resultRows = $this->fetchAll($query);
    	return $resultRows;

Anyone know what I could be doing wrong? I want to get all the columns in 'games' to show and the 'rank' column in the ranks table.

© Stack Overflow or respective owner

Related posts about sql

Related posts about join