I am trying to output some data formatted differently for each row, using $this->datatables->add_column(); but it is not working for some reason.
Controller Code:
$this->datatables->select('project_id, name, status, end_date')
->unset_column('end_date');
$this->datatables->add_column('end_date', check_deadline('$1'), 'end_date')
$this->datatables->from('projects');
echo $this->datatables->generate();Helper Function:
function check_deadline($date)
{
if (trim($date) == '0000-00-00')
{
return "Ongoing";
}
else
{
return trim($date);
}
}As the end result, I either get EVERY row to say ‘Ongoing’ or as the actual date, including if it is 0000-00-00.
Am I using this function in the wrong way? Any help greatly appreciated.
EDIT: So I am thinking this function just gets evaluated once, and the variable replacement is done AFTER the function is evaluated. Is there a way I can make it do what I want? Thanks!