0
votes

[Cakephp 2.5.4]

I would like to insert a new entry into a table with only one primary auto-increment key.

I have 2 tables :

mytables (id[A_I],name,sequence_id)
sequences (id[A_I])

I trying to insert data into a transaction using "saveAssociated" function:

$data = array(
    'MyTable' => array(
        'name' => 'test'
    ),
    'Sequence' => array()
);

Then

$this->MyTable->saveAssociated($data);

Associations between MyTable and Sequence are well defined into each Model. By the way the transaction always rollback.

If I add a new field into sequences table it works..

  • How can I succeed this transaction keeping an unique field into sequences table
1

1 Answers

0
votes

Do you wanna save a new record on a single field to succeed the transaction? If is this, you can use the method below:

$this->ModelName->id = $id;
$this->ModelName->saveField('field', 'new record');

Sorry if wasn't this.