cphalcon
cphalcon copied to clipboard
[bug?]Model and default value in mysql
Im use mysqul, example table:
id name (not null) isActive (not null, default = 1) #1
$model = new model();
$model->name = 'test';
$model->save(); // return null
#2
[...]
$model = new model();
$model->name = 'test';
$model->isActive = 1;
$model->save(); // return 1
Why #1 dont work?
save() never returns "null" or "1", it returns true or false
As the column "isActive" is marked as "not null" you must tell Phalcon to use the default value explicitly by using a raw value with "default" or by skipping columns in the insert.
http://docs.phalconphp.com/en/1.1.0/reference/models.html#skipping-columns
I do not know if it's the best solution, but get used to it. ;-)