diff --git a/Admin/Install/db.json b/Admin/Install/db.json index c7e3788..04a3c4c 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -51,9 +51,9 @@ "type": "VARCHAR(100)", "null": false }, - "currency_num": { - "name": "currency_num", - "type": "VARCHAR(3)", + "currency_number": { + "name": "currency_number", + "type": "SMALLINT(4)", "null": false }, "currency_symbol": { diff --git a/Admin/Installer.php b/Admin/Installer.php index b878371..8098d07 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -45,6 +45,7 @@ final class Installer extends InstallerAbstract ]); self::installLanguages($sqlite, $dbPool); + self::installCurrencies($sqlite, $dbPool); $sqlite->close(); } @@ -83,4 +84,42 @@ final class Installer extends InstallerAbstract $query->execute(); } + + /** + * Install currencies + * + * @param SQLiteConnection $sqlite SQLLite database connection of the source data + * @param DatabasePool $dbPool Database pool to save data to + * + * @return void + * + * @since 1.0.0 + */ + private static function installCurrencies(SQLiteConnection $sqlite, DatabasePool $dbPool) : void + { + $con = $dbPool->get(); + + $query = new Builder($con); + $query->prefix($con->getPrefix()) + ->insert('currency_id', 'currency_name', 'currency_char', 'currency_number', 'currency_symbol', 'currency_subunits', 'currency_decimals', 'currency_countries') + ->into('currency'); + + $querySqlite = new Builder($sqlite); + $currencies = $querySqlite->select('*')->from('currency')->execute(); + + foreach ($currencies as $currency) { + $query->values( + $currency['currency_id'], + $currency['currency_name'], + $currency['currency_char'], + $currency['currency_number'], + $currency['currency_symbol'], + $currency['currency_subunits'], + $currency['currency_decimals'], + $currency['currency_countries'] + ); + } + + $query->execute(); + } }