开发者

limitPage() with some JOINs in Zend Framework

Programmers.

I have the next SELECT statement, created using Zend Framework:

$select = $this->select()
    ->from('post')
    ->setIntegrityCheck(false)
    ->join('post_category', 'post.category_id = post_category.id', array(
    开发者_如何学Go    'category_name' => 'name',
        'category_name_key' => 'name_key'))
    ->joinLeft('post_comment', 'post_comment.post_id = post.id', array(
        'comment', 'comment_date_creation' => 'date_creation'))
    ->limitPage(2, 10);

But it is one problem in limitPage(). For example I have 100 rows in post table. And after JOINing SELECT returns (for example) 200 rows. But I should LIMIT only rows from the post table with all relations. How can I do it in ONE query using Zend Framework?


The real question is how would you do it in plain SQL?! IMO you can't do that in SQL. And that is the very reason you can't do that using Zend_Db_Select either ;) Update your post with the plain SQL query you would use and I would tell you how to write that using Zend_Db.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜