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
Post a Comment