CakePHP Save hasOne data: constraint error -


hey new cakephp , want know why code doesnt work:

$data['gender'] = array(     'bezeichnung'   => $item['person']['gender'] ); $data['client'] = array(     'id'        => $item['person']['person_id'],     'vorname'   => $item['person']['firstname'],     'nachname'  => $item['person']['lastname'],     'gender_id' => $this->client->gender->id );  $this->client->create(); $this->client->saveall($data); 

i want create new entry in database using saveall command having $data holding related data.

the error following: sqlstate[23000]: integrity constraint violation: 1452 cannot add or update child row: foreign key constraint fails

my client model:

public $hasone = array(     'gender' => array(         'classname' => 'gender',         'foreignkey' => 'gender_id'     ) ); 

my gender model:

public $tableprefix = 'fixed_'; public $validate = array(     'bezeichnung' => 'isunique' ); 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -