module training - clean code with trims and fix one SQL method

This commit is contained in:
Rodney Figaro 2017-03-30 09:25:52 +02:00
parent f5619c158f
commit 87fe55d4e7

View File

@ -68,10 +68,10 @@ class TrainingFixedCodeClient extends ObjectModel
// load all already saved codes
foreach (Db::getInstance()->executeS('
SELECT TRIM(`codeclient_from_results`) as `codeclient_from_results`, TRIM(`codeclient_fixed`) as `codeclient_fixed`
SELECT `codeclient_from_results`, `codeclient_fixed`
FROM `'._DB_PREFIX_.'training_fixedcodeclient`
') as $row) {
$existing_codes[$row['codeclient_from_results']] = $row['codeclient_fixed'];
$existing_codes[trim($row['codeclient_from_results'])] = trim($row['codeclient_fixed']);
}
// insert new wrong codes with their correction
@ -107,11 +107,11 @@ class TrainingFixedCodeClient extends ObjectModel
{
$result = new ArrayExtended();
$sql = 'SELECT TRIM(`codeclient_from_results`), TRIM(`codeclient_fixed`)
$sql = 'SELECT `codeclient_from_results`, `codeclient_fixed`
FROM `'._DB_PREFIX_.'training_fixedcodeclient`
WHERE codeclient_fixed <> \'\'';
WHERE TRIM(`codeclient_fixed`) <> \'\'';
foreach (Db::getInstance()->executeS($sql) as $row) {
$result[$row['codeclient_from_results']] = $row['codeclient_fixed'];
$result[trim($row['codeclient_from_results'])] = trim($row['codeclient_fixed']);
}
return $result;
@ -122,16 +122,16 @@ class TrainingFixedCodeClient extends ObjectModel
// get already saved codes to correct
$existing_codes = array();
$sql = 'SELECT LOWER(TRIM(`codeclient_from_results`)) as `codeclient_from_results`
$sql = 'SELECT LOWER(`codeclient_from_results`) as `codeclient_from_results`
FROM `'._DB_PREFIX_.'training_fixedcodeclient`';
foreach (Db::getInstance()->executeS($sql) as $row) {
$existing_codes[] = $row['codeclient_from_results'];
$existing_codes[] = trim($row['codeclient_from_results']);
}
// remove duplicate keys
$unique_pharmacies_not_found = array();
foreach ($pharmacies_not_found as $key => $val) {
$key = strtolower($key);
$key = strtolower(trim($key));
if (!isset($unique_pharmacies_not_found[$key])) {
$unique_pharmacies_not_found[$key] = $val;
}