I have a few tables that are joined through a distant relationship - for example:
A.id = B.a_id, B.id = C.b_id, C.id = D.c_id
And given A.id
, I want to delete all the rows in D
that are associated with A.id
.
Since Model::deleteAll()
does not accept any joins, only conditions, how do I go about it?
All the models (A, B, C, D) already have belongTo
relationships defined.
My last resort would be raw SQL, but I would like to know if there's a way in CakePHP to do it.
I could not find similar questions as they all were about deleting ALL the associated data, rather than just one table's data via an associated key.