CodeIgniter Forums
nice to have before and after for insertBatch - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: nice to have before and after for insertBatch (/showthread.php?tid=80989)



nice to have before and after for insertBatch - Anwar - 01-11-2022

Hello, 
Would be nice to have in modal's beforeInsertBatch and afterInsertBatch. I'm seeing insertBatch very usefull for large imports and having also the ability to manipultate the data before inserting would be a great thing. 
In this moment I'm using db->insert() just because I have afterInsert hook, and takes 18 seconds to do it from a loop. while with insertBatch I get 600ms response time. 
Thank you


RE: nice to have before and after for insertBatch - MGatner - 01-17-2022

Great idea! I could see that being highly useful. I don’t think this would be difficult to add, seeing as all the code is already there it just needs to be adapted for the “batch” methods. Would you be willing to try creating a Pull Request?


RE: nice to have before and after for insertBatch - yklow 84 - 01-31-2022

Hi, there will also nice event point from following place.
- before query
- before commit
- after commit
- before render (after controller)
- exception (before render)
If have those event points, will very helpful and more flexible


RE: nice to have before and after for insertBatch - kenjis - 02-24-2023

$beforeInsertBatch, $afterInsertBatch, $beforeUpdateBatch and $afterUpdateBatch can be used since v4.3.0.
https://codeigniter4.github.io/CodeIgniter4/models/model.html#model-events