CodeIgniter Forums
saving with foreign key.... - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: saving with foreign key.... (/thread-44187.html)

saving with foreign key.... - El Forum - 08-06-2011

Hi guys!

I'm new of CodeIgniter.
I have a problem with savign a new Objetc with reference key...
$anag = new Anagrafica();
            $user = new User();
            $user->login = 'Adelaide';
            $user->password = 'adelaide43';
            $user->email = '[email protected]';

this is the error...

A Database Error Occurred
Error Number: 1452

Cannot add or update a child row: a foreign key constraint fails (`minijob`.`an_user`, CONSTRAINT `an_user_ibfk_1` FOREIGN KEY (`anagrafica_id`) REFERENCES `an_agrafica` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE)

INSERT INTO `an_user` (`login`, `password`, `email`) VALUES ('Adelaide', 'adelaide43', '[email protected]')

Filename: /Applications/MAMP/htdocs/minijob/libraries/Datamapper.php

Line Number: 1713