show(array($f[0], $warn), $f[1]);
 }
 if (mysql_select_db(@$_GET['dbname']) || $dbconn && mysql_select_db($DBName)) {
     show(GM('MYSQL_SELECT_DB'), 1, 0);
     $name = create_tmp_table(true);
     // InnoDB
     $res = mysql_query("SHOW CREATE TABLE {$name}");
     $f = mysql_fetch_row($res);
     $val = preg_match("#ENGINE=InnoDB#", $f[1]);
     show(array(GM('INNODB'), '', 2), $val, !$val);
     if ($name) {
         mysql_query("DROP TABLE " . $name);
     }
     // Temporary table
     debug(__LINE__);
     $name = create_tmp_table();
     if ($name) {
         show(array(GM('DB_TEST_TABLE'), '', 1), 1, 0);
         $t1 = microtime_float();
         $good = true;
         // Insert 1000 rows
         debug(__LINE__);
         for ($i = 0; $i < 1000; $i++) {
             if (!mysql_query("INSERT INTO " . $name . " VALUES ('test1','test2','test3','test4')")) {
                 $good = false;
                 break;
             }
         }
         if ($good) {
             $t2 = microtime_float();
             $pr = array(GM('INSERT'), GM('INSERT_D'));
Exemple #2
0
 $uplo->params = array('path' => CSHOP_MEDIA_FULLPATH, 'ws_path' => CSHOP_MEDIA_URLPATH, 'fnamebase' => uniqid('inventory-data.000'));
 $res = $uplo->save_upload();
 if (PEAR::isError($res)) {
     $errs[] = $res->getMessage();
 } else {
     $newfilename = $uplo->get_newname();
     // get the name of the new file
     $fullpathfile = $uplo->fullPathtoFile;
     ini_set('auto_detect_line_endings', 1);
     if (!($fh = fopen($fullpathfile, "r"))) {
         $errs[] = "Unable to open uploaded file data. Can not continue.";
     } else {
         $skus_found = 0;
         $notfound = array();
         $skip_first_row = isset($_POST['skip_first_row']);
         $res = create_tmp_table($mdb);
         $cols = join(',', array_keys($datafile_pos));
         $sql = "INSERT INTO tmp_inv ({$cols})\n                                     VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
         if (!($sth_insert_tmp_row = $mdb->prepare($sql, null, MDB2_PREPARE_MANIP))) {
             $errs[] = "Could not prepare the database insert.";
         }
         $sth_get_sku = $mdb->prepare("SELECT product_id FROM cm_inventory WHERE sku = ?");
         $seen_skus = array();
         while (($data = fgetcsv($fh, 64000, ",")) !== FALSE) {
             if ($skip_first_row) {
                 $skip_first_row = false;
                 continue;
             }
             if (count($data) != $datafile_expected_cols) {
                 $errs[] = "Datafile does not seem to be correctly formatted.";
                 break;