Error with 2 relations with same table

image from my project
i have a solicitacao with 2 cidades! cidade_id and cidade_id2
but when i add a solicitacao
error:

Fatal error: Uncaught exception ‘epExceptionDbAdodb’ with message 'Cannot execute query: mysql error: [1452: Cannot add or update a child row: a foreign key constraint fails (confianza/solicitacao, CONSTRAINT FKsolicitaca716252 FOREIGN KEY (cidade_id2) REFERENCES cidade (id))] in EXECUTE(“INSERT INTO solicitacao (cidade_id) VALUES (1)”) ’ in /home/xxx/workPHP/confianza/lib/phporm/src/db/epDbAdodb.php:188 Stack trace: #0 /home/xxx/workPHP/confianza/lib/phporm/src/db/epDb.php(352): epDbAdodb->_execute(‘INSERT INTO sol…’) #1 /home/xxx/workPHP/confianza/lib/phporm/src/db/epDbObject.php(3581): epDb->execute(‘INSERT INTO sol…’) #2 /home/xxx/workPHP/confianza/lib/phporm/src/db/epDbObject.php(2560): epDbObject->_execute(‘INSERT INTO sol…’) #3 /home/xxx/workPHP/confianza/lib/phporm/src/runtime/epManager.php(1191): epDbObject->insert(Object(epClassMap), Object(epObject)) #4 /home/xxx/workPHP/confianza/lib/phporm/src/runtime/epManager.php(1147): epManagerBase->_commit_o(Object(epObject)) #5 /home/hu in /home/xxx/workPHP/confianza/lib/phporm/src/db/epDbAdodb.php on line 188

if in solicitacao have only one cidade (FK), its work fine

can help?


Entity Relationship Diagram1.jpg

Hello Hussan,

According to you model you should set both reference of cidade from solicitacao below save. Can you send me the complete code fragment you used to save solicitacao?

Best regards,
Rain