public function __construct($channelId, Db $db) { $getChannelInfosSql = <<<EOT \t\t\tSELECT \t\t\t\tchannels.channels_name, \t\t\t\tchannels.comment_on_order, \t\t\t\tchannels.languages_code, \t\t\t\tgros.gros_customers_id, \t\t\t\tgros.gros_currency, \t\t\t\tlanguages.languages_id, \t\t\t\tcurrencies.value, \t\t\t\tcurrencies.symbol_left, \t\t\t\tcurrencies.decimal_places, \t\t\t\tcurrencies.decimal_point, \t\t\t\tcurrencies.thousands_point, \t\t\t\tcurrencies.symbol_right \t\t\tFROM \t\t\t\tgros \t\t\t\tLEFT JOIN channels \t\t\t\t\tON channels.channels_id IN (gros.gros_id, 0) \t\t\t\tLEFT JOIN languages \t\t\t\t\tON languages.code = channels.languages_code \t\t\t\tLEFT JOIN currencies \t\t\t\t\tON currencies.code = gros.gros_currency \t\t\tWHERE \t\t\t\tgros.gros_id = :channelId \t\t\tORDER BY \t\t\t\tchannels.channels_id DESC \t\t\tLIMIT \t\t\t\t1 EOT; $sqlParams = array("channelId" => $channelId); $channelInfos = $db->getOneRow($getChannelInfosSql, $sqlParams); if (false == $channelInfos) { throw new \InvalidArgumentException("Can't find channel with id {$channelId}"); } $this->id = $channelId; $this->name = $channelInfos->channels_name; $this->customersId = $channelInfos->gros_customers_id; $this->commentOnOrder = $channelInfos->comment_on_order; $this->paymentMethod = "Paiement via {$this->name}"; $this->languageCode = $channelInfos->languages_code; $this->languageId = $channelInfos->languages_id; $this->currencyCode = $channelInfos->gros_currency; $this->currencyValue = $channelInfos->value; $this->currencyDecimalPlaces = $channelInfos->decimal_places; $this->currencyDecimalPoint = $channelInfos->decimal_point; $this->currencyThousandsPoint = $channelInfos->thousands_point; $this->currencySymbolLeft = $channelInfos->symbol_left; $this->currencySymbolRight = $channelInfos->symbol_right; }
public static function findByIso3Code($iso3Code, Db $db) { $getCountryInfosSql = <<<EOT \t\t\tSELECT \t\t\t\tcountries_id, \t\t\t\tcountries_name \t\t\tFROM \t\t\t\tcountries \t\t\tWHERE \t\t\t\tcountries_iso_code_3 = :iso3Code \t\t\t\tAND countries_active = 1 \t\t\tLIMIT \t\t\t\t1 EOT; $sqlParams = array("iso3Code" => strtoupper($iso3Code)); $countryInfos = $db->getOneRow($getCountryInfosSql, $sqlParams); if (false == $countryInfos) { throw new \InvalidArgumentException("Can't find country with iso3 code >{$iso3Code}<"); } return new OkCountry($countryInfos->countries_id, $countryInfos->countries_name); }
public static function deleteTestsOrders(IniParams $iniParams, Db $db) { $selectOkOrdersId = "SELECT orders_id FROM orders WHERE channels_id = :channelId"; $sqlParams = array("channelId" => $iniParams->get("channelId")); $okOrdersIdArray = $db->getAll($selectOkOrdersId, $sqlParams); if ($okOrdersIdArray) { foreach ($okOrdersIdArray as $okOrderId) { $sqlParams = array("okOrderId" => $okOrderId->orders_id); $deleteSql = "DELETE FROM orders WHERE orders_id = :okOrderId"; $db->execute($deleteSql, $sqlParams); $deleteSql = "DELETE FROM orders_products WHERE orders_id = :okOrderId"; $db->execute($deleteSql, $sqlParams); $deleteSql = "DELETE FROM orders_status_history WHERE orders_id = :okOrderId"; $db->execute($deleteSql, $sqlParams); $deleteSql = "DELETE FROM orders_total WHERE orders_id = :okOrderId"; $db->execute($deleteSql, $sqlParams); } } }