prepare for currency table

This commit is contained in:
Dennis Eichhorn 2020-02-03 18:34:02 +01:00
parent 6bbe3f8f6f
commit 083ff79109
2 changed files with 42 additions and 3 deletions

View File

@ -51,9 +51,9 @@
"type": "VARCHAR(100)", "type": "VARCHAR(100)",
"null": false "null": false
}, },
"currency_num": { "currency_number": {
"name": "currency_num", "name": "currency_number",
"type": "VARCHAR(3)", "type": "SMALLINT(4)",
"null": false "null": false
}, },
"currency_symbol": { "currency_symbol": {

View File

@ -45,6 +45,7 @@ final class Installer extends InstallerAbstract
]); ]);
self::installLanguages($sqlite, $dbPool); self::installLanguages($sqlite, $dbPool);
self::installCurrencies($sqlite, $dbPool);
$sqlite->close(); $sqlite->close();
} }
@ -83,4 +84,42 @@ final class Installer extends InstallerAbstract
$query->execute(); $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();
}
} }