我有这个函数,并且得到了一个错误 PDO::exec()
:-
private function pdo()
{
$path = File::get($_SERVER['DOCUMENT_ROOT'] . '\storage\uploadedReports\report.csv');
try {
$pdo = DB::connection()->getPdo();
$loadCsv = $pdo->prepare("LOAD DATA LOCAL INFILE '" . $path . "'
INTO TABLE records
FIELDS TERMINATED BY ',' enclosed by '\"' lines terminated by '\n'
(percentage_artist_name, provider_name, sub_provider_name, @date, tune_code, tune_name,
category, sub_category, sub_type, downloads, total_revenue, @created_at, @updated_at)
SET `date` = date_format(@`date`,'%Y-%c-%d'), created_at = NOW(), updated_at = NOW()");
$pdo->exec($loadCsv);
} catch (\Exception $e) {
dd($e->getMessage());
}
}
我该怎么修?
提前谢谢。
2条答案
按热度按时间bzzcjhmw1#
方法$pdo->prepare返回一个statement对象。使用此对象可以调用execute方法。在execute方法中,如果查询有参数标记(?)?或:参数(名称)。
试试这个:
希望这有帮助。
8fq7wneg2#