[eluser]jprateragg[/eluser]
I need to insert a null date using ActiveRecord. I have a helper function that converts the date to the MySQL date format:
Code:
function convert_date($input) {
if(strlen($input) > 0) {
$d = preg_split('#[-/:. ]#', $input);
if (is_array($d) && count($d) == 3) {
if (checkdate($d[0], $d[1], $d[2])) {
$output = "$d[2]-$d[0]-$d[1]";
}
}
} else {
$output = "NULL";
}
return $output;
}
Here is my model where I save the data:
Code:
public function save_analysis_history($data) {
$this->db->where('id', $this->analysis_id);
$this->db->update('analysis_history', $data);
}
This is the error I'm getting:
Code:
Error Number: 1292
Incorrect date value: 'NULL' for column 'bs_effective_date' at row 1
UPDATE `analysis_history` SET `bs_effective_date` = 'NULL' WHERE `id` = '156'
Is it possible to get ActiveRecord to not add single quotes to NULL?