2012-06-05 5 views
0

한 번에 100 개의 메시지를 보내는 Codeigniter에서 메일 대기열을 개발하고 있습니다. 이 작업을 수행하는 가장 좋은 방법을 찾고 있으며 $this->db->insert_batch()을 발견했습니다. 유용하게 보이지만 사용법에 대한 정보는 찾을 수 없습니다. 누구든지 우편으로 사용 했습니까?Codeigniter when insert_batch()를 사용하는 경우

$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') 

답변

2

당신은이 데이터베이스에 데이터를 삽입하는 데 사용하기 때문에 (분명히) 목적을 이메일 용 $this->db->insert_batch()을 사용할 수 없습니다. 대신 CodeIgniter Email Class을 사용하면됩니다.

$this->load->library('email'); 

$this->email->from('[email protected]', 'Your Name'); 
$this->email->to('[email protected]'); // Send the email to yourself to see how it looks 
$this->email->bcc('...'); // Pass in a comma-delimited list of email addresses or an array 

$this->email->subject('Email Test'); 
$this->email->message('Testing the email class.'); 

$this->email->send(); 

제 생각에는 CodeIgniter를 사용하여 많은 사용자에게 이메일을 보내는 가장 좋은 방법입니다.

+0

죄송합니다. 코드를 다르게 해석했습니다. 루프에서 전자 메일 클래스를 사용하고 있지만 (개별 메시지를 각각 다른 메시지로 보내야 함) 한 번에 최소 100 개를 보내야합니다. "일괄 처리"소리가 오른쪽 – CyberJunkie

+0

@CyberJunkie 그 경우에는 간단한 루프가 괜찮을 것입니다. 수령인과 이메일 메시지 (및 필요한 경우 제목)를 변경하기 만하면됩니다. –

관련 문제