⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

check if datetime field is null



Ron

Ron
  • profile picture
  • Member

Posted 26 March 2014 - 20:40 PM

How do I check if the field Original_Time is null?

$crud->callback_before_update(array($this,'check_Original_ETA'));


function check_Original_ETA($value, $primary_key)
{
$this -> db -> select('Original_ETA');
        $this -> db -> from('table');
        $this -> db -> where('id = ' . "'" . $primary_key . "'");
        $this -> db -> limit(1);
        $query = $this -> db -> get();
$row = $query->row();


$str = $row->Original_ETA;

if ($str != NULL)
{
   $crud->change_field_type('Original_ETA', 'readonly');
}
}

Code above is not working. Basically if field 'Original_Time' is already filled I don't want the user to be able to change this field again. 

 

So I think I have two issues here. How to check for Null in DateTime and also how to set a field ReadOnly going to EDIT screen depending on a field value.

 

Thank you for helping.


Ron

Ron
  • profile picture
  • Member

Posted 28 March 2014 - 18:46 PM

Got it myself. Set the mysql tbl to default value '0000-00-00 00:00:00' and then check for that value  ... $crud->where('Delivered =', '0000-00-00 00:00:00');