0

I have a problem with inserting some xml names to mysql. What I would like for it to do is insert 1 then 2 then 3, and increment by 1, etc... But it jumps from 1-21 (increments of '1' are fine from 1-21) then it insert by another thousand and it gets even bigger after. (every 1,285,268 rows are skipped for inserting one row).

Here is what I am trying to accomplish: I am importing xml file names from a shared folder (windows server) on my web server (ubuntu 14.01). The shared xml folder I placed where my main dashboard web page could access and inside my main dashboard a php script imports the names and inserts into mysql. Then if a xml file name already exists in mysql db table the column is set for unique and cannot be duplicated (and is checked by php). But if neither xml names match a mysql row it inserts a new row in mysql. It would be nice if it increments by one and not a million times. Here is my script that imports the xml name into mysql from the shared folder:

<?php
$log_dir = "/var/www/public/xml/";
$results_array = array();

if(is_dir($log_dir)) {
   if($take = opendir($log_dir)) {
      while(($file = readdir($take)) !== false) {
          $results_array[] = $file;
      }
      closedir($take);
   }
} //end log_dir
foreach($results_array as $value) {
   $eExt = substr($value, -18);
   $eDate = substr($eExt, 0, -4);
   $checkDB = $db->query("select `num` from `report`;");
   if(!empty($eDate)) {
       foreach($checkDB->results() as $check) {
         if($check->dateString != $eDate) {
          $addFiles = $db->query("insert into `report` (`num`) values ('$eDate')");
         } // this is double the assurance it won't duplicate
       }
   }
} //end foreach

Thank you!!!

smor
  • 39
  • 2
  • 7
  • The solution from that answer is MyISAM but I really need InnoDB... I cannot change the engine.. Thanks for the suggestion though, so looks like I am out of luck then... Solution for the duplicate suggestion by hakre: MyISAM does not exhibit this behavior, since it's AUTO_INCREMENT algorithm is implemented differently (due to its limited ability to support concurrent DML). – smor Mar 27 '15 at 17:15
  • No, it's the way you read it. My personal standpoint is that you shouldn't care at all. The only important thing is that the ID is unique, there is no distinction of it being determinable. Next to that I strongly recommend you to look for existing Q&A on this website first. I close only against one of the many duplicates the topic you ask about has. For writing a new question it's important to outline why and how your question is different from the existing ones and why the existing answers didn't make it for you (and no, I didn't care about myisam at all, just to make that perfectly clear). – hakre Mar 27 '15 at 21:19

0 Answers0