我想合併這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