cakephp3 how to check there is no linked data before delete

102 views Asked by At

I have 2 tables: table1 and table2

There are linked with :

table1 hasmany table2

I do not want to delete row from table1 if there is linked data in table2

I guess I have to use $rules->addDelete to do that ?

What is the best check ?

Do I have to build a

select from table2 where table1_id=$id ?

0

There are 0 answers