I have been experiencing a very strange issue. I am trying to do a save on a Model, but I keep getting the following when I var_dump $model->getMessages():
array(1) { [0]=> object(Phalcon\Mvc\Model\Message)#102 (4) { ["_type":protected]=> string(19) "ConstraintViolation" ["_message":protected]=> string(54) "Value of field "id" does not exist on referenced table" ["_field":protected]=> string(2) "id" ["_model":protected]=> NULL } }
Now, I know for a fact that I am getting a result from when I run Projects::findFirst() (here is the gist of the var_dump() https://gist.github.com/dasfisch/3d5ca322ea1cf81fd42f). I always get a result, but, as soon as I try to save it, I get a ConstraintViolation. This ONLY happens in our development environment, which runs 0.9.1 (my local runs 0.9.0). I have not had a problem running save() on any models, only this one. Here is the model (https://gist.github.com/dasfisch/014dc029017dd0569825). I can provide the action, if necessary.
My concern is why the model is found when I am doing a search, but not found when I am trying to update it. Is there a way I can take a look at the last query that was run against the model? I couldn't find anything anything in the docs (if I missed something, I'd appreciate any info). Another thing that worries me is why _model in the Model\Message class is null? Shouldn't that loop back to the appropriate model? I tested this locally, hardcoding a non-existing ID, and I got the same result.
I'm sorry for the extreme amount of information, but I am at my wit's end as to what is going wrong. Any help would be appreciated.
Thanks in advance.