I have a table in MariaDB configured like this:
CREATE TABLE orders ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, ... createdAt DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, createdBy INT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id) );
I called create () after setting the values except id, createdAt, createdBy. The result was true. id returns the correct value. After that, setting a value in another field and update() will return false. The error is "PresenceOf" and it says "createdAt is required", "createdBy is required".
$odr = new Models\Orders(); $odr->someField = 'foo'; $result = $odr->create(); // return true $id = $odr->id; // get valid value $odr->anotherField = 'bar'; $result = $odr->update(); // return false
After create(), a valid value is set in id. Is the value not reflected in other than that? (Values that have not been explicitly set remain null) Is it necessary to re-acquire by using firstFirst(), etc. in order to match the value on the table (= default value is reflected)?