If the table has default values for certain fields and NULL is not allowed, you can expect the script insert to use these default values, as MariaDB / MySQL usually does. For example, if the table products have an AI field "id", a required field "name" and two required fields "active" and "featured", which are equal to 1 by default, then the request
INSERT INTO products (name) VALUES ('someName');
automatically inserts 1 as the value of the active and recognized. However, when using such Phalcon models:
$product = new Products();
$product->setName('someName');
$product->save();
returns validation errors that require "active" and "recognized".
Is there a flag that I must provide during model generation so that the Phalcon tools harvest and enter default values in the model classes, or is there another way to force Phalcon to automatically use the default values if they are found? I believe that a better approach would simply ignore fields that have not been set. Can I make these models?
source
share