Skip to content

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