We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

DB tables default values

Hello,

we are started to move our website to phalcon. Now I have a little question/problem. We migrated our db tables with the phalcon dev tools to a model. Now we need the define for every value a new RawValue. Is it possible the do that automatically, for example with a paramater that i must set in the config ?

Thx for your help and sry for my bad english :)



2.1k

If your database table already has a default value. you just have to not place any value for the model when saving it.

If you are talking about initializing some specific value yourself before saving in php.

public function beforeSave()
{
    $this->myfield = "my default value in php":
}

you can also specify which fields to skip specifically by using meta-data

https://docs.phalcon.io/en/latest/reference/models.html#meta-data-strategies