I’m developing a mailing queue in Codeigniter that sends 100 messages at a time. I’m searching for the best way to do this and came across $this->db->insert_batch(). It looks useful but I can’t find information on when or how to use it. Has anyone used it for mailing purposes?
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name' ,
'date' => 'My date'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name' ,
'date' => 'Another date'
)
);
$this->db->insert_batch('mytable', $data);
// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')
You can’t use
$this->db->insert_batch()for emailing purposes (obviously) because it’s used to insert data into the database. What you can do is use CodeIgniter Email Class instead.In my opinion, this would be the best way to send an email to a lot of users using CodeIgniter.