#2056: [PATCH] afterFind and beforeFind methods should be called on associated
models
----------------------------+-----------------------------------------------
Reporter: maular | Owner:
Type: Enhancement | Status: new
Priority: Medium | Milestone: 1.3.x.x
Component: Model | Version:
Severity: Trivial | Resolution:
Keywords: | Php_version: PHP 4 >= 4.3.0
Cake_version: 4451 |
----------------------------+-----------------------------------------------
Comment (by Chaso):
Yes, you could add the handling of associated models into afterFind of the
primary model, but...
1) ...you have to add this code to all models which have this model as
association. And you have to handle all associations in your afterFind.
What if one is bound/unbound 'on the fly'? You will get into serious
problems!
2) ...you will have more DB calls (If the behaviors beforeFind joins
tables, like on Translate - see below)
3) ...this will not effect the SELECT COUNT or LIMIT statement of these
calls. If you goin to filter out unwanted results in afterFind, the
count/limit will not be correct
Example for 2)
Translate behavior joines i18n table in beforeFind, so if you have I18n
Fields in an associated model they will not be loaded.
If you want to add this functionality to your primary models beforeFind,
you will have to load this data 'by hand' which adds as much DB calls, as
you have results in your association!
Example for 3)
If you have something like soft-delete or ACL, which does not allow access
to all rows and you're goin to filter the results in afterFind, something
like LIMIT 20 will give you a result between 0 and 20 results (depends on
how many have been filtered out in afterFind)
Changing dbo_source is the ONLY way without drawbacks! (Except that some
behaviors have to be updated, too)
--
Ticket URL: <https://trac.cakephp.org/ticket/2056#comment:15>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---