Пример #1
0
 printout('- import_dn_tall_ikkeimportert cleaned');
 // Getting shops => we are using all areas with shop_id set
 $shops = array();
 $areas = array();
 $Q = mysql_query("SELECT id AS area_id, area_name, importdatanova_shop_id AS shop_id, importdatanova_alert_email FROM `mrbs_area` WHERE importdatanova_shop_id != 0 && importdatanova_shop_id != ''");
 printout('Shops being imported (areas that has shop_id set):');
 while ($R = mysql_fetch_assoc($Q)) {
     $shops[$R['shop_id']] = $R['area_id'];
     $areas[$R['area_id']] = $R;
     printout('- Shop id ' . $R['shop_id'] . ', ' . $R['area_name'] . ' (area id ' . $R['area_id'] . ')');
 }
 // Analyze data
 printout('Analyzing data rows');
 $data_analyzed = datanova_analyze_data($data_rows, $shops);
 printout('Putting new data in database');
 $numbers_new = datanova_databaseinsert($data_analyzed['numbers_new']);
 printout('New numbers imported: ' . $numbers_new);
 printout('Updating data in database');
 $numbers_updated = datanova_databaseupdate($data_analyzed['numbers_update']);
 printout('Updated numbers (delete+insert): ' . $numbers_updated);
 printout('Putting unknown goods (goods id & shop id combinations) in database for review');
 $numbers_updated_notimported = datanova_databaseupdate_notimported($data_analyzed['unknowns']);
 printout('Numbers of unknown goods: ' . $numbers_updated_notimported);
 printout('Unknown goods ignored (goods id, shop id and day combinations): ' . count($data_analyzed['numbers_ignored_notreged']));
 printout('Ignored: ' . count($data_analyzed['numbers_ignored_reged']));
 printout('Already imported: ' . count($data_analyzed['numbers_alreadyimported']));
 if (count($data_analyzed['unknowns'])) {
     printout('');
     printout('Unknown goods:');
     $unknowns_per_shop = array();
     foreach ($data_analyzed['unknowns'] as $unknown) {
Пример #2
0
function datanova_databaseupdate($numbers_update)
{
    if (count($numbers_update)) {
        foreach ($numbers_update as $vare) {
            mysql_query("DELETE FROM `import_dn_tall` WHERE\r\n\t\t\t\t\t`vare_nr` = '" . $vare['vare_nr'] . "' AND\r\n\t\t\t\t\t`shop_id` = '" . $vare['shop_id'] . "' AND\r\n\t\t\t\t\t`dag`     = '" . $vare['dag'] . "'\r\n\t\t\t\tLIMIT 1;");
            if (mysql_error()) {
                throw new Exception('MySQL error when deleting numbers (' . print_r($vare, true) . ') from database: ' . mysql_error());
            }
        }
        return datanova_databaseinsert($numbers_update);
    } else {
        return 0;
    }
}