I have semicolon-separated .dat
file and I want to read that file and store its contents into a database.
Structure of .dat
file:
Enforce inserting only on the right datatype.
if(is_numeric($data[0])){
...
your code
...
}
More correctly, you should be enforcing that the columns don't allow insertion of bad data at the database level, so your listed columns should be of integer type since they're ids, not of whatever type they are currently (varchar, perhaps). And you could then handle errors appropriately, e.g. by ignoring and discarding inappropriate data.