There is a table Test (id(primary AUTO_INCREMENT), text) I do:

 $test = new Test(); $test -> text = 'test1'; $test -> save(); 

I assume that the auto-increment value is written in the id field, but no ... the record is not saved at all. $test->getErrors() says "ID cannot be blank."

If you do this, then everything works:

 $test -> id = 1; $test -> text = 'test1'; $test -> save(); 

How to do so not to explicitly specify the value of the id field?

  • one
    probably id for some reason entered in the rules () of the model - kroder
  • truly! So it is, thanks for the help! - Monitorkin

1 answer 1

Reply from comments

Check the rules() method of the model responsible for validation; there should be no rules for the id field.