Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

mapper::erase() and beforetrigger()/aftertrigger() not called when $filter specified

25 views
Skip to first unread message

PJH

unread,
Apr 11, 2025, 9:24:14 AMApr 11
to Fat-Free Framework
A quick perusal of the source code shows that neither beforetrigger() or aftertrigger() are called if $filter is not null.

Is this intended or an oversight?

If the former, is the only way to get the triggers fired to reorganise my code to do a find() then iterate through the returned records one by one and do an erase(null)?

PJH

unread,
Apr 11, 2025, 9:35:10 AMApr 11
to Fat-Free Framework
.. I did of course mean the  beforeerase() and aftererase() triggers...

PJH

unread,
Apr 13, 2025, 6:31:28 AMApr 13
to Fat-Free Framework
Found the solution - pass `false` as the second parameter, and it'll do the iteration itself (resulting in the triggers being called.)

The documentation at https://fatfreeframework.com/3.9/sql-mapper#erase probably needs some attention - it specifies that the hooks aren't called if $filter is specified, but doesn't have $quick in the function signature, and as a result doesn't specify what $quick does.
Reply all
Reply to author
Forward
0 new messages