cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

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

Open phatnt93 opened this issue 4 years ago • 2 comments

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

  • Phalcon version: 4.1.2
  • PHP Version: 7.4.27
  • Operating System: Docker linux
  • Installation type: Compiling from source || installing via package manager
  • Zephir version (if any): Version 0.12.21-8a412a1
  • Server: Apache
  • Database: mariadb 10.5.9

phatnt93 avatar May 28 '22 12:05 phatnt93

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.

borisdelev avatar Jun 09 '22 06:06 borisdelev

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]

phatnt93 avatar Jun 09 '22 07:06 phatnt93