From 7e1fa66c5a4cd69454bf71102ed98fdbca2b9389 Mon Sep 17 00:00:00 2001 From: upcesar Date: Thu, 2 Jul 2015 16:38:22 -0300 Subject: [PATCH 1/2] Added insert_batch to use with the mapped table in the model --- core/MY_Model.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/MY_Model.php b/core/MY_Model.php index 05add98..c1082b5 100644 --- a/core/MY_Model.php +++ b/core/MY_Model.php @@ -243,6 +243,19 @@ public function insert_many($data, $skip_validation = FALSE) return $ids; } + /** + * Insert rows in batch into the table instead of doing one by one. + * This method is faster than "insert_many", but beware of passing unvalidated data, since this + * method does not deploy class validation nor db trigger execution either. + * Returns true on success or false otherwise. + */ + public function insert_batch($data) + { + $result = $this->db->insert_batch($this->_table, $data); + + return $result; + } + /** * Updated a record based on the primary value. */ From eee8147032bf41527b3e1e8ba68aaa627516a775 Mon Sep 17 00:00:00 2001 From: upcesar Date: Thu, 2 Jul 2015 17:15:08 -0300 Subject: [PATCH 2/2] Replace native ->db for ->_database --- core/MY_Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/MY_Model.php b/core/MY_Model.php index c1082b5..a22c036 100644 --- a/core/MY_Model.php +++ b/core/MY_Model.php @@ -251,7 +251,7 @@ public function insert_many($data, $skip_validation = FALSE) */ public function insert_batch($data) { - $result = $this->db->insert_batch($this->_table, $data); + $result = $this->_database->insert_batch($this->_table, $data); return $result; }