Open
Description
Hi!
according to Model.php, in function create, we always have a model even if
the save has failed:
public static function create($attributes, $validate=true) { $class_name = get_called_class(); $model = new $class_name($attributes); $model->save($validate); return $model; }
what is the best way to handle a failed save? I'm using is_new_record attribute to check if the model has been saved or not.
Is this the correct way ?
Or better not use create and use initialize+save directly ?
Or, is reasonable to change the create function to:
public static function create($attributes, $validate=true) { $class_name = get_called_class(); $model = new $class_name($attributes); $res = $model->save($validate); if ( $res ) return $model; else return $res; }
regards,
mat