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

Model id is '0'

Hey! I've been using Phalcon for some time now and just hit a new exciting issue - ONE of my models is unable to save to the DB - an email confirmation entity that is created alongside a user. The user is successfully created and inserted, but the confirmation is not. This worked before the weekend, but seeing as it is Monday, something has to go wrong.

Their ID column is the same:

int(10) unsigned (auto increment)

In my controller:

var_dump($confirmation->save()); // true
var_dump($confirmation->getMessages()); // array (size=0) empty
var_dump($confirmation->refresh()); // public 'id' => string '0' (length=1)

In the model:

public function afterCreate(){
  if(!$this->id){
    throw new \Exception("WTF"); // is thrown
   }
}

I have looked at this discussion and tried what it says (using create() etc), but nothing seems to work. I'm losing my mind!! Please help!!

Hi @kyree can you share the table difinition and your enviroment (SO, PHP and Phalcon versiĆ³n, DB Server)???