2012-04-28 10 views
1

zend paginatorアダプターで左結合のグループの前に注文する方法はありますか?一般にグループの前にZendフレームワークの注文

new Zend_Paginator_Adapter_DbSelect($this->db->select() 
->from(array('a' => $this->prefix.'contest'), array('id')) 
->joinLeft(array('b' => $this->prefix.'logo_to_contest'),'a.id=b.contest_id', array('img')) 
->group('a.id') 
->order('a.end','a.date_start DESC','b.id RAND()') 
) 

答えて

2
のMySQLマヌエルから

、使用される句は 構文記述に示さ正確ために与えられなければなりません。たとえば、HAVING句は、 のGROUP BY句の後、および任意のORDER BY句の前に来なければなりません。例外は、 です。INTO句は、構文 の説明またはselect_exprリストの直後のいずれかに表示される可能性があります。

syntax descriptionグループで、それはそれはあなたが注文前にグループを置くことが必要ですMySQLのZendの とは何の関係もありませんので、オーダーの前に来ます。

$subselect = $db->select() 
->from(array('a' => $this->prefix.'contest'), array('id')) 
->joinLeft(array('b' => $this->prefix.'logo_to_contest'),'a.id=b.contest_id', array()) 
->order('a.end','a.date_start DESC','b.id RAND()'); 

$select = $db->select()->from(a(array('a' => $this->prefix.'contest'), array('id')) 
->joinLeft(array('b' => $this->prefix.'logo_to_contest'),'a.id=b.contest_id', array('img')) 
->where("a.id in ($subselect)") 
->group('a.id'); 
:しかし、新しいのグループは次のように選択するには、順序でサブクエリを選択することができます注文後、この問題とグループを回避する

関連する問題