我想将这 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