Recursive option like CakePHP in zend framework

2019-09-06 00:09发布

问题:

i am new in zend framework i want the same functionality in zend framework like recursive which i am using in cake php. any one can help me to implement this in zend framework ? anyone know how to implement the same thing in zend framework ?

回答1:

The recursive property defines how deep CakePHP should go to fetch associated model data via find(), findAll() and read() methods.
Imagine your application features Groups which belong to a domain and have many Users which in turn have many Articles. You can set $recursive to different values based on the amount of data you want back from a $this->Group->find() call:
Depth   Description
-1  Cake fetches Group data only, no joins.
0   Cake fetches Group data and its domain
1   Cake fetches a Group, its domain and its associated Users
2   Cake fetches a Group, its domain, its associated Users, and the Users' associated Articles
Set it no higher than you need. Having CakePHP fetch data you aren’t going to use slows your app unnecessarily. Also note that the default recursive level is 

If this is what you are asking about, you can have it or something like it as soon as you code it or install an ORM like Doctrine. :)
The best you're likely to do with vanilla ZF is something like findDependentRowset() or findParentRow().
ZF gives you the tools to build what you need it's not a black box style framework like some others. However it's usually not to hard to bolt on libraries and third party tools.