I have a range of date that I wich to add a row in my table foreach slected day of the week, so i needed a trigger to do that because this must be done after an insert on another table , and i'm facing some errors, so here is my code hoping that you can tell me what i have done wrong !
$begin = $this->input->post('debut_semestre');
$end = $this->input->post('fin_semestre');
$end = $end->modify( '+1 day' );
$array_jour = array();
$interval = new DateInterval('P7D');
$daterange = new DatePeriod($begin, $interval ,$end);
foreach ($daterange as $key ) {
$array_jour[] = $key->format("Y-m-d");
}
$this->db->query("create or replace trigger 'insert_seance'
after insert on 'emploi'
foreach row begin".
foreach ($array_jour as $key) {."
INSERT INTO seance(id, Date, jour, id_salle, id_groupe, id_ens, id_mat, de, a, etat, id_semestre) VALUES (null,".$key.",".$jour.",".$id_salle.",".$id_groupe.",".$id_ens.",".$id_mat.",".$date_debut.",".$date_fin."'active',".$id_semestre." )
".}."
)";