0

I'm building an interface to create multiple records in the db, using Codeigniter.

The input is text copied and pasted from an Excel file, with the fields names in the top row.

Parsing that text and converting it into an array is easy enough. But I try to think what would be the best way to validate the data before inserting it into the database (make sure all the not-null fields are filled, all the integer fields are numeric, all the foreign keys are valid, etc.).

I'm looking for something similar to the form validation rules in CI. Any pointers as to where I should start looking?

1 Answer 1

1

Well! this is only some idea i am not posting any code here.
Create a library and define methods for integer , numeric and foreign keys.
if any does not contain any data fill it with default means if string then with '' and if integer then with 0 and so on. Now create methods to run validation and do some logic as how you want to display errors. i have done the same thing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.