1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
/**
* Deletes the SalesPrices that are included in the range
*
* @param Date $lowerStart A starting_date
* @param Date $higherEnd An ending_date
*
* @return nothing
* @todo Find a DQL way to do SQL job
*/
protected function deletePricesIn($lowerStart, $higherEnd)
{
$PDO = Doctrine_Manager::getInstance()->connection()->getDbh();
$PDO->prepare(
" DELETE FROM toy_master_price_list WHERE id IN ("
. " SELECT id FROM ("
. " SELECT mpl.id FROM toy_master_price_list AS mpl INNER JOIN toy_price_list_product AS tpp"
. " WHERE"
. " EXISTS ("
. " SELECT 1 FROM toy_discount_matrix AS dm INNER JOIN toy_discount_matrix_product AS dmp"
. " WHERE dm.id = '" . $this->source->getId() . "'"
. " AND dm.type = '" . $this->getDiscountMatrixType() . "'"
. " AND dmp.discount_matrix_id = dm.id"
. " AND dmp.product_id = tpp.product_id"
. " AND dmp.market_id = tpp.market_id"
. " AND dm.title = mpl.title"
. " )"
. " AND tpp.master_price_list_id = mpl.id"
. " AND mpl.type <= '" . $this->getMasterPriceListType() . "'"
. " AND mpl.starting_date >= '$lowerStart'"
. " AND mpl.ending_date <= '$higherEnd'"
. " )"
. " t)"
)->execute();
} |
Partager