Jump to content


check if datetime field is null

datetime null

  • Please log in to reply
1 reply to this topic

#1 Ron

Ron

    Member

  • Members
  • PipPip
  • 19 posts

Posted 26 March 2014 - 08: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.



#2 Ron

Ron

    Member

  • Members
  • PipPip
  • 19 posts

Posted 28 March 2014 - 06: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');







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users