我想合并这2个请求在1,但我不知道如何做到这一点。任何想法 ?学说:合并2请求1
$productsCount = Doctrine::getTable('Product')
->createQuery('p')
->where('p.store_id = ?', $store_id)
->andWhere('p.collection = ?', $this->product->getCollection())
->andWhere('p.image_path IS NOT NULL')
->count();
$productsCollection = Doctrine::getTable('Product')
->createQuery('p')
->where('p.store_id = ?', $store_id)
->andWhere('p.collection = ?', $this->product->getCollection())
->andWhere('p.status_id = ?', Product::_ONLINE)
->andWhere('p.id<>?', $this->product_id)
->offset(rand(0, $productsCount - 1))
->execute();
- 学说:1.2
- 的Symfony:1.4
- PHP:5.3
你想要的到底是什么?这2个查询返回不同的信息,你想如何合并它们? – j0k
这两个查询使用相同的表,第一个使用第二个,所以我认为这可能会更好地做到这一点,以优化这一点。但也许我错了? – MaximeBernard