I have an array with multiple elements. The size of the array isn’t always the same.
At the moment the only way I can think of doing is using a foreach loop and querying the database once for every element in the array.
What I am looking for a way to insert one row for one element in the array but all in one query. I would like to do is using codeigniter’s active record class so that I wouldn’t have to write code to check for malicious data and such.
Use
insert_batchif you just want one query:All values are escaped automatically.
Docs: http://codeigniter.com/user_guide/database/active_record.html#insert