Added insert_batch to use with the mapped table in the model #208
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, this CI Extension Class helped me a lot for encapsulating some native plumbing db model methods. When I searched for a "insert_batch()" method in this extended class (for further info: https://ellislab.com/codeigniter/user-guide/database/active_record.html#insert) , I didn't found it and I didn't want to use the native CI method, because I had to pass 2 parameters, just like this:
$this->db->insert_batch(string $table_name, array $data);
Searching I've found the method insert_many(), but it also loops to add one by one. That why I created this method in the extension class, since it's faster adding records in batch, saving time and requests with DB Server.
With this new merthod, you anyone can use it like this, since it uses default table name:
$this->my_model->insert_batch(array $data);
Keep in mind the data must be validated before passing to this method.