Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug?]Model and default value in mysql #606

Closed
Cmssspl opened this issue May 4, 2013 · 2 comments
Closed

[bug?]Model and default value in mysql #606

Cmssspl opened this issue May 4, 2013 · 2 comments

Comments

@Cmssspl
Copy link

Cmssspl commented May 4, 2013

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?

@phalcon
Copy link
Collaborator

phalcon commented May 4, 2013

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

@Cmssspl
Copy link
Author

Cmssspl commented May 4, 2013

I do not know if it's the best solution, but get used to it. ;-)

@Cmssspl Cmssspl closed this as completed May 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant