phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.78k stars 1.97k forks source link

[BUG]: Model afterDelete event, can't use delete, update method on result of relationship #15972

Closed phatnt93 closed 2 years ago

phatnt93 commented 2 years ago

Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord

Describe the bug [Model] When use delete, update method from result of relationship in afterDelete event. It's not working. But check delete, update method still exists in object result

To Reproduce image

Steps to reproduce the behavior:

  1. Declare relationship in model class
  2. In afterDelete event, use delete or update method from result of relationship
  3. Error

Expected behavior Use delete, update method.

Screenshots Declare relationship for category childs, post-category map image

afterDelete event in model image

Error when delete category then delete child categories image

Details

borisdelev commented 2 years ago

Hmm... i think is not related with models, because ::update() method is not on stdClass. However, if you want to delete child elements, you can use foreignKey in relation... or in DB - with index and foreign key.

phatnt93 commented 2 years ago

Thanks.

It does not work with relation (index and index). But work with relation (index and foreign key).

parent[index] code [index] cate_code [index]