public static function storeCouponCount($couponId)
{
$idExists = 0;
if ((int) $couponId > 0) {
$db = Factory::getDBO();
$query = ' SELECT id FROM #__phocacart_coupon_count WHERE coupon_id = ' . (int) $couponId . ' ORDER BY id LIMIT 1';
$db->setQuery($query);
$idExists = $db->loadResult();
if ((int) $idExists > 0) {
$query = 'UPDATE #__phocacart_coupon_count SET count = count + 1 WHERE id = ' . (int) $idExists;
$db->setQuery($query);
$db->execute();
} else {
$valuesString = '(' . (int) $couponId . ', 1)';
$query = ' INSERT INTO #__phocacart_coupon_count (coupon_id, count) VALUES ' . (string) $valuesString;
$db->setQuery($query);
$db->execute();
}
return true;
}
return false;
}