Hi everyone,
I'have some trouble with callback_before_update.
It seems to the callback is ignored...
$crud->callback_before_update(array($this,'addition_cout_participants'));
function
function addition_cout_participants($post_array, $primary_key)
{
$this->db = $this->load->database('formations', true);
$this->db->select('personne_id');
$this->db->where('participation_id', $primary_key);
$query = $this->db->get('join_pepa');
$nb_participant = 0;
if ($query->num_rows() > 0)
{
foreach ($query-result() as $row)
{
$nb_participant++;
}
}
$montant_total = $post_array['coutFormation'] * $nb_participant;
$post_array['coutTotal'] = $montant_total;
return $post_array;
}
that not work !
If I try a simple thing like
function addition_cout_participants($post_array, $primary_key)
{
$post_array['coutTotal'] = 12;
return $post_array;
}
$post_array['coutTotal'] is always: 0.00 ; the default value in db (in my db_table coutTotal is a decimal(10,2) field)
I also try
$this->db->where('participation_id', $primary_key);
$this->db->update('join_pepa', array('coutTotal'=>$montant_total));
But nothing...
Someone can help me ?
Thanks
