Welcome Guest, Not a member yet? Register   Sign In
saving with foreign key....
#1

[eluser]Unknown[/eluser]
Hi guys!

I'm new of CodeIgniter.
I have a problem with savign a new Objetc with reference key...
Code:
$anag = new Anagrafica();
            $anag->where('NOME','test')->get();
        
            $user = new User();
            $user->login = 'Adelaide';
            $user->password = 'adelaide43';
            $user->email = '[email protected]';
            
            
             $user->skip_validation()->save($anag)

this is the error...

Code:
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


Messages In This Thread
saving with foreign key.... - by El Forum - 08-06-2011, 10:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB