开发者

Limit models to select

开发者 https://www.devze.com 2023-02-12 22:20 出处:网络
I have a database table called Event which in CakePHP has its relationships coded to like so: var $belongsTo = array(\'Sport\');

I have a database table called Event which in CakePHP has its relationships coded to like so:

var $belongsTo = array('Sport');
var $hasOne = array('Result', 'Point', 'Writeup', 'Timetable', 'Photo');

Now am doing a query and only want to pull out Sport, Point, and Timetable

Which would result开发者_开发问答 in me retrieving Sports, Events, Points, and Timetable.

Reason for not pulling everything is due the results having 17000+ rows.

Is there a way to only select those tables using:

$this->Event->find('all');

I have had a look at the API but can't see how its done.


You should set recursive to -1 in your app_model and only pull the things you require. never use recursive of 2 and http://book.cakephp.org/view/1323/Containable is awesome.

just $this->Event->find('all', array('contain' => array()));

if you do the trick of recursive as -1 in app_model, this is not needed, if would just be find('all') like you have

0

精彩评论

暂无评论...
验证码 换一张
取 消