Closed WanWizard closed 13 years ago
Commented to receive updates on this feature
Actually, this relates to my comment to this commit: https://github.com/fuel/orm/commit/de3724eacf56a58a7641940462bce7d8f09a19c7
Default values should be set in the model's $_properties static variable, not by the DB for the reasons I gave there.
I think the docs needs more info on $_properties, and need to include a note not to use DB defaults, because this is going to confuse people.
Yeah, I know, I need to write more docs...
hi, could you give me a hint for the syntax to define a default value via the $_properties variable?
i tried using something like 'manual_check' => '0' in the properties array which seems to work. but when i try do do a select like Model_Project::find($id_project) on that model, the system tries to select a table field named '0' which, of cause, doesn't exist.
any help would be really appreciated.
class Model_Example extends Orm\Model {
protected static $_properties = array(
'prop' => array(
'default' => 'value'
),
);
}
And next time: use the forums, that's where questions should go.
thanks! unfortunately still no luck. i started a new topic on this at http://fuelphp.com/forums/topics/view/2903
Currently, Model::create() generates an insert for all defined columns, whether they are assigned a value or not.
This means that you'll get an error on columns defined as 'NOT NULL' when no value is set, even though the database has a default value defined.