如何在Joomla模型中执行LOAD DATA LOCAL INFILE

I want to import up to 10.000 record to database (mysql) in joomla Models. In tho controller file, i was create an CSV file from uploaded data file by user, and then passing the file to models.

I've been test the query in MySQL comand promt, and its work fine. All record in CSV that created by Conroller file was imported. But i got an error while execute query on joomla, with no definition error. Joomla run on localhost, ubuntu 18.04 desktop.

Here's my controller file:

//writing csv file
        $csv_file = $path."csv_file_ok_". round(microtime(true)) .".csv";
        $create_csv = fopen($csv_file,"w");
        $b= 0;
        foreach($key_index as $lines)
        {
            if($b == 0)
            {
                fputcsv($create_csv, array_keys($lines));
            }
            else
            {
                fputcsv($create_csv, $lines);
            }
            $b++;

        }

        fclose($create_csv);
        chmod($csv_file, 0755);
        //chown($csv_file, mysql:mysql);
        $model = $this->getModel();
        $model->saveReservation($csv_file);

and this is my model:

public function saveReservation($file)
    {
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $sql = "TRUNCATE TABLE ". $db->quoteName('#__service_reservation');
        $db->setQuery($sql);

        $del = $db->execute();

        if($del)
        {   
            $query = $db->getQuery(true);
            $sql = 'LOAD DATA LOCAL INFILE ' . $db->quote($file) .
                   ' INTO TABLE ' . $db->quoteName('#__service_reservation') .
                   ' FIELDS TERMINATED BY '. $db->quote(',') . ' ENCLOSED BY '. $db->quote(' ').
                   ' LINES TERMINATED BY \'
\' '.
                   ' IGNORE 1 ROWS ' .
                   ' (plnt,reserv_no,item,material_no,reqmt_qty,bun,withdrwl_q,balance_qt,mvt,sloc,rcvsloc,reqmt_date,base_date,recipient,text)';

            //echo $sql;

            $db->setQuery($sql);
            echo($query->__toString());
            $res = $db->execute();
            //return $res;
        }

and this is part of my csv file:

plnt,reserv_no,item,material_no,reqmt_qty,bun,withdrwl_q,balance_qt,mvt,sloc,rcvsloc,reqmt_date,base_date,recipient,text
3DP0,0011988450,5,EM120WH-35,1,PC,0,-1,9X3,8101,1090,2018-07-13,2018-07-13,9Y4,"IBU RINI -PONDOK PINANG"
3DP0,0012267262,3,9LCEJC20YRD19,1,PC,0,-1,9X3,8101,1090,2018-08-27,2018-08-27,9Y4,"100481683 FELICIA GRACE-IBU -SDSS SERPONG"
3DP0,0012361530,16,DSGY-G525JBKZ,1,PC,0,-1,9X3,8101,3190,2018-12-10,2018-09-10,601,"HEIN SASS"
3DP0,0012381155,10,1627A47205-MD,1,PC,0,-1,9X3,8101,1091,2018-09-13,2018-09-13,REFURBISH,

run on Mysql promt:

mysql> LOAD DATA LOCAL INFILE '/var/www/html/cs/tmp/csv_file_ok_1557531392.csv' INTO TABLE `q26f3_service_reservation` FIELDS TERMINATED BY ',' ENCLOSED BY '' LINES TERMINATED BY '
' IGNORE 1 ROWS (plnt,reserv_no,item,material_no,reqmt_qty,bun,withdrwl_q,balance_qt,mvt,sloc,rcvsloc,reqmt_date,base_date,recipient,text);
Query OK, 2944 rows affected (1.45 sec)
Records: 2944  Deleted: 0  Skipped: 0  Warnings: 0

but joomla give me error:


If difficulties persist, please contact the System Administrator of this site and report the error below.

    0
    /var/www/html/cs/libraries/joomla/database/driver/mysqli.php:665