user147
user147

Reputation: 1310

CakePhp record is deleted,but it should be updated?

I have edit screen that should edit in several tables some data,problem is that,that data isn't edited,it is deleted after I submit it.Everything looks fine,what could be the problem?

I didn't pass any code here,because code is huge,so can someone just give me a hint where to search to fix this problem.

model relationship :

TableA has many : TableB,TableC,TableD

TableB belongs to : TableA has many : TableD,TableE,TableF

TableC belongs to : TableA

TableD - nothing

TableE has many : Table F

TableF - nothing

I'm not pro in cakephp,and databe isn't mine,I can't change it. Hope you undestand me

Upvotes: 0

Views: 105

Answers (1)

Scott Harwell
Scott Harwell

Reputation: 7465

It is hard to unstand what happening without any code example. The only thing i can think of that would cause something like this is a habtm relationship. If the relationship is has and belongs to many, the the existing records are deleted before save. You can change your model so that the relationship sets unique to false and it should stop deleting each relationship record on save...

public $hasAndBelongsToMany => array(
    'modelB' => array(
        'unique' => false
    )
);

If you don't have a habtm relationship, could you provide your model code as an example?

Upvotes: 1

Related Questions