0

クエリでSQL_CALC_FOUND_ROWSを使用しようとしています。しかし、 AS Expression1がないとクエリを作成できません

$select = $this->getSql()->select();
            $select->columns(array("*", new Expression(" SQL_CALC_FOUND_ROWS *")));
            $select->join( array ( 
                    'c2h' => 'site_category2help_topic' ), 'c2h.help_topic_id = site_help_topic.help_topic_id', array ( 
                    "*" ) );
            $select->where( " c2h.category_id = $categoryId " );
            $select->limit($limit);
            $select->offset($offset);

結果:

SELECT site_help_topic.*, SQL_CALC_FOUND_ROWS * *AS Expression1*, c2h.* 

FROM site_help_topic 

INNER JOIN site_category2help_topic AS c2h 

ON c2h.help_topic_id = site_help_topic.help_topic_id 

WHERE c2h.category_id = 5 LIMIT '15' OFFSET '0'

そのはず :

SELECT site_help_topic.*, SQL_CALC_FOUND_ROWS *, c2h.* 

FROM site_help_topic 

INNER JOIN site_category2help_topic AS c2h 

ON c2h.help_topic_id = site_help_topic.help_topic_id 

WHERE c2h.category_id = 5 LIMIT '15' OFFSET '0'
4

1 に答える 1

1

Sql\Select にはオプションがありQUANTIFIER、列名として指定する代わりにそれを使用できるはずです。

こちらと同様にZend\Db\TableGateway で SQL_CALC_FOUND_ROWS を使用する方法

于 2013-04-16T20:51:28.447 に答える