Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

i can insert data from mysql, but i try to insert from phalcon and the SQLSTATE[23000] shows up

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (laboratoriocygnus.datospersonales, CONSTRAINT fk_datosPersonales_usuario1 FOREIGN KEY (usuario) REFERENCES usuario (id) ON DELETE NO ACTION ON UPDATE NO ACTION)



1.2k
Accepted
answer

it's sql error. you try add or update row where foreign key is empty or not exist in dependent table.

edited Feb '19

it's working now, i use phalcon model table --force, maybe i change something in the model and that generated the problem