Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added insert_batch to use with the mapped table in the model #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

upcesar
Copy link

@upcesar upcesar commented Jul 2, 2015

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.

@michail1982
Copy link

@upcesar , use $this->_database instate of $this->db

@upcesar upcesar closed this Mar 23, 2016
@upcesar upcesar reopened this Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants