I have a callback function which needs to add the recently entered datetime, and time from a different table. However, it updates the db with null. I tried re-updating it with the initial datetime input and it works fine. I'm guessing the problem is along the addition part. HELP!
Here's the callback...
function add_path_after_insert($post_array,$primary_key)
{
$this->load->model('admin_model');
$pdep=$this->admin_model->get_pathDep($primary_key);
$sdep=$this->admin_model->get_schedDep($primary_key);
$currentDate = strtotime($pdep);
$futureDate = $currentDate+(((int)substr($sdep,0,2))*3600)+(((int)substr($sdep,3,2)) * 60) + ((int) substr($sdep,6,2));
$data = array(
'dep_datetime' => $futureDate
);
$this->db->where('path_id', $primary_key);
$this->db->update('path', $data);
return true;
}
From the model...
function get_schedDep($path_id)
{
$query=$this->db->query('SELECT dep_time FROM schedule JOIN path ON schedule.sched_id= path.sched_id WHERE path_id="'.$path_id.'"');
$row=$query->row();
return $row->dep_time;
}
function get_pathDep($path_id)
{
$query=$this->db->query('SELECT dep_datetime FROM path WHERE path_id="'.$path_id.'"');
$row=$query->row();
return $row->dep_datetime;
}
