i need to convert the following query in laravel 5.4
$loadDataToTempTableSql = "LOAD DATA LOCAL INFILE '".$filename."' INTO TABLE ABC FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '
' IGNORE 1 LINES";
$loadDataToTempTableRes = mysqli_query($link,$loadDataToTempTableSql);
$loadedData = mysqli_affected_rows($link);
what i did
Step1:
DB::select($load_data_to_temp_table_sql);
which is throwing exception:
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while
other unbuffered queries are active. Consider using
PDOStatement::fetchAll(). Alternatively, if your code is only ever
going to run against mysql, you may enable query buffering by setting
the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. (SQL: LOAD DATA
LOCAL INFILE
'/Library/WebServer/Documents/public/abc
copy.csv' INTO TABLE ABC FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '
' IGNORE 1 LINES)
Step2:
$pdo = DB::connection()->getPdo();
$pdo->exec($load_data_to_temp_table_sql);
again exception:
PDO::exec(): LOAD DATA LOCAL INFILE forbidden
Please guide, what to do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…