Support the ongoing development of Laravel.io →
Database Eloquent

I have something that I'm trying to do that is probably against the norm, but here is what I'm doing.

I am loading a huge amount of data into the database within Laravel. Since the data is so massive (potentially millions of records in one file), I would run into memory errors if I looped it naturally. Since I'm using MySQL, I decided to use the Load Infile option. So, to do this within Laravel I did this (keeping in mind I'm keeping this example simple, I have a number of checks and what not):

$query = "LOAD DATA INFILE..."
DB::getPdo()->exec($query);

This works perfect, data gets loaded in. The problem I'm having is that I don't know how to grab the response in this context. I would like to try and log any error (or any response at all if I can). I could do it in straight PDO, but I'm not sure how using Laravel's methods. Or even if it's possible. If anyone has ran into this before and has a suggestion, that would be great.

Thank you.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Yelldon yelldon Joined 2 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.