diff --git a/src/Model.php b/src/Model.php index b010906..35a1c7f 100644 --- a/src/Model.php +++ b/src/Model.php @@ -139,6 +139,9 @@ class Model{ protected static function convertField($data, $field){ $options = static::getOptions($field); + if(is_null($data) && isset($options['not_null']) && $options['not_null'] == true) + throw new DatabaseException('Can\'t set null to NOT NULL field : '.$field); + if(isset($options['type'])){ switch(strtolower($options['type'])){ case 'int': @@ -157,9 +160,6 @@ class Model{ } } - if(is_null($data) && isset($options['not_null']) && $options['not_null'] == true) - throw new DatabaseException('Can\'t set null to NOT NULL field : '.$field); - return $data; }