Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Integrity constraint violation
  • Hello, sorry but English is not my native language.
    We encounter a problem with the orm.
    We define our tables like this: \Model_Contact
     protected static $_belongs_to = array(
            'adresse' => array(
                'key_from' => 'adresse',
                'model_to' => 'Model_Adresse',
                'key_to' => 'idadresse',
                'cascade_save' => true,
                'cascade_delete' => false,
            'typecontact' => array(
                'key_from' => 'typecontact',
                'model_to' => 'Model_Type_contact',
                'key_to' => 'idtypecontact',
                'cascade_save' => true,
                'cascade_delete' => false,
        protected static $_properties = array(

    protected static $_has_many = array(
            'contact' => array(
                'key_from' => 'idtypecontact',
                'model_to' => 'Model_Contact',
                'key_to' => 'typecontact',
                'cascade_save' => false,
                'cascade_delete' => false,
        protected static $_properties = array(

    When making the save, we have an error that we are not able to debug
    Fuel\Core\Database_Exception [ Error ]: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`gesta4`.`contact`, CONSTRAINT `FK_4C62E638593B531F` FOREIGN KEY (`typeContact`) REFERENCES `type_contact` (`idTypeContact`)) with query: "INSERT INTO `contact` (`tcivilite`, `tnom`, `tprenom`, `participant`, `stage`) VALUES ('Madame', 'Gglerj', 'Fdsfoh', '35', null)"

    Thank you for your help

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!