You don't necessarily need a package for this; basic PHP commands can get the job done. If you want a more thorough answer, then you'll have to elaborate on the specifics of what you're attempting to do. Size of files, frequency of import, etc.
And even if this is a recurring process, then you can still take this approach. I would only reach for a package if this import functionality is a core feature of your application that gets implemented in numerous ways. If it's just one component, then I would stick to plain PHP.
@lbecket One last thing, in this csv file I have a field 'status', but in my database that field is a foreing key and it is 'status_id', how can I solve this problem?
@lbecket I have to solve a test.
My task is to add a functionality to upload a csv file and save the data in the db.
The csv file looks like this:
name employer status date
Jhon Jim Completed 11/12/2021
The status field that is the in the csv, I have it as a status_id in my db, since I have a status table containing all the statuses.
Now when I upload this file I don't need 'Completed' for example, but I need a fk, for example 1
@Kris01 Why are you storing the status in a reference table and not directly on the record? That seems like an unnecessary level of complexity for no apparent gain. This situation alone demonstrates why it's a bad idea.
Second, if you're trying to solve this problem for a test, isn't it cheating if I simply tell you how to solve it?
@lbecket I am storing the status that way, so In the future if the administrator wants to add another status,
let's say we now have only completed and pending, and in future we might want failed, so that's the reason.
I asked a question, if someone is open to help, they're welcome, if not that's another thing.
@Kris01 I think it's obvious that I'm willing to help. My point was simply that the goal for you is clearly education and you're not going to learn if someone solves the problem for you. If you're stuck along the way, which happens to all of us, then asking for guidance is fine. I'm honestly trying to be helpful.
Regarding the reference table, the possibility of a new status is irrelevant since you would still need to update/insert new FK values. Keeping a second table doesn't simplify this, it complicates it. Now, if you decided that you wanted to change the wording of a status, "Completed" to "Complete" for example, then that might be justification, but I would argue that 1) this is unlikely and 2) you can simply run an update query against the base table to update that value. Storing the status on your base table not only simplifies your data model, but it solves your import problem.