插入过程中未输入某些数据

时间:2018-02-02 08:50:17

标签: php mysql file glob

我试图从2个不同的目录中获取数据,但是具有相同的格式数据,我在数据库中放置的目录名称。当相同类型时,它应该插入另一个具有不同头的表,因为来自2个不同的目录。 当我回显$ query时,它显示来自2目录的所有数据。但只插入一个目录中的数据。

这是

表2

INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('1','CAMPUS10','CAMPUS10','Print','32429 ELLY','1400.175049 x 2749.550049 cm','2018-01-28 19:00:58','2018-01-28 19:00:58')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('1','CAMPUS10','CAMPUS10','Print','32429 ELLY','1400.175049 x 2747.786133 cm','2018-01-28 19:41:41','2018-01-28 19:41:41')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('1','CAMPUS10','CAMPUS10','Print','32429 ELLY','1400.175049 x 2749.550049 cm','2018-01-28 20:07:11','2018-01-28 20:07:11')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('1','CAMPUS10','CAMPUS10','Print','32273 PRINTING_YOPIE','1500.011108 x 1000.125000 cm','2018-01-24 19:49:32','2018-01-24 19:49:32')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('1','CAMPUS10','CAMPUS10','Print','46x46_bantal_fix.tif ','1080.205566 x 369.711121 cm','2018-01-30 15:55:11','2018-01-30 15:55:11')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('3','CAMPUS12','CAMPUS12','Print','Sali - rzq_1Feb18 + reject 1x.tif ','1299.986084 x 920.044434 cm','2018-02-01 12:29:59','2018-02-01 12:29:59')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('3','CAMPUS12','CAMPUS12','Print','kode 4 3x.tif ','470.252777 x 940.152771 cm','2018-01-31 20:03:20','2018-01-31 20:03:20')
INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('3','CAMPUS12','CAMPUS12','Print','kode 9 3x.tif ','470.252777 x 940.152771 cm','2018-01-31 19:54:15','2018-01-31 19:54:15')

但是当点击插入时,只输入所有数据campus10,而不是campus12。

表1

CMPTR_NBR    CMPTR_NAME    MACH_TYP      DIR_NAME
    1        CAMPUS10      MVJ1624     C://xampp/htdocs/Champion/machine-logs/LogCampusMesinMutoh/*.job 
    2        CAMPUS12      MVJ1624     C://xampp/htdocs/Champion/machine-logs/LogCampusMesinMutoh2/*.job 

这是代码插入的片段函数

else if ($row['MACH_TYP'] == 'MVJ1624') 
{

    foreach (glob($row['DIR_NAME'])as $job) { //local
        // echo $job."<br>";
    if (file_exists($job)) { 
        $path           = file_get_contents($job);
        $File           = '/File=(.*)/';
        $PrintSetup     = '/PrintSetup=(.*)/';
        $SourceSizeX    = '/SourceSizeX=(.*)/';
        $SourceSizeY    = '/SourceSizeY=(.*)/';
        $Filelg         = '/File=(.*)/';

        preg_match($File,         $path, $Filematch);
        preg_match($PrintSetup,   $path, $PrintSetupmatch);
        preg_match($SourceSizeX,  $path, $SourceSizeXmatch);
        preg_match($SourceSizeY,  $path, $SourceSizeYmatch);
        preg_match($Filelg,       $path, $Filelgmatch);

        $kol     = $Filelgmatch[1];

        $str     = str_replace('File=', '', $kol);

        $folders = explode('\\', $str);
        $realtime = date("Y-m-d H:i:s", filemtime($job));
        $time = date('Y-m-d H:i:s',strtotime($realtime.'+ 6 hour'));
         // echo $time."<br>";

        $dimensi = $SourceSizeXmatch[1]." x ".$SourceSizeYmatch[1]." cm";

        $testing = $folders[6];
        $query = "INSERT INTO CMP.LOG_FILE(CMPTR_NBR,PRN_TTL,PRN_DESC,PRN_TYP,FIL_NM,PRN_DIM,BEG_TS,END_TS) VALUES ('".$row['CMPTR_NBR']."','".$row['CMPTR_NAME']."','".$row['CMPTR_NAME']."','Print','".$testing."','".$dimensi."','".$time."','".$time."')";
          echo $query."<br>";
        // $result = mysql_query($query);
                }
        }
    }

0 个答案:

没有答案