I’m trying to figure out what could be the reason for this exiting problem:
Im saving a row with save() functions which returns true.
After save() function, if I call var_dump($model->id), it prints every time id number, which is
1 more than before(as It has to do becouse there is auto_increment in MySQL database.)
Also I inserted manually one row in phpmyadmin to my table, I gave it id 325. After doing save() operations many times, there are no more rows in table
but every time I call var_dump($model->id) it is printing like 326, 327…354, 355… and so on.
So, the auto_increment is working like there would be more rows, but there are just only one which I inserted manually.
I’m thinking could it be problem with MySQl better than Yii?
I have other tables which are working correctly with save() function. Also the ActiveRecords should be correctly generated and in date.
I someone has intelligence to give me ideas, I would be very pleased.
Also, that counters increment independetly if the sql row is inserted or not. Try to see the generated sql and use that one in mysql and see what errrors throw.
I have a problem when use ->rollBack (in beginTransaction). save of model canceled (as expect that) but the next time the new record (that succesfully saved) has very next id.
for example if the last record has id=100 and we use rollback for new record, the next saved record will has id=102 (and not 101)
whats wrong?? (obviously rollback fuction delete the saved record)
How prevent that? I want the new successfully record has the appropiate id.
zaccaria is right about the possibilities (they are not many but they exist), you have minimized them but if a web site has too many traffic the problem continues.
I think that depends from the mysql. if we attempt to change auto_increment while two or more users save records then auto_increment does not change.