0

我在使用 Paginator-> 设置时遇到问题。由于某种原因,递归不起作用。有任何想法吗?我已经尝试设置 $this->Cheese->recursive = 2 并且没有任何运气。

$this->Cheese->recursive = 2;
$this->Paginator->settings = array(
        'CheeseCheckin' => array(
        'fields' => array('id','created','comment','location','rating','short_url_hash','foursquare_id'),
        'conditions'=>array(
            'CheeseCheckin.cheese_id' => $id
        ),
        'contain' => array(
            'Cheese'=>array(
                'fields' => array('id','name','created','modified','attachment_id'),
                'Attachment' => array(
                    'fields' => array('id','name','ext','path')
                )
            ),
            'CheeseProducer' => array(
                'fields' => array('name','created', 'id','attachment_id')
            ),
            'User' => array(
                'fields' => $this->userFields,
                'Attachment' => array(
                    'fields'=>array('id','name','ext','path')
                ),
                'StateRegion' => array(
                    'fields'=>array('name','code')
                ),
                'Country' => array(
                    'fields'=>array('name','code')
                )
            ),
            'Place' => array(
                'fields'=>array('id','name')
            ),
            'UserAttachment' => array(
                'fields' => array('id','ext','name','path')
            )
        ),
        'page' => $page,
        'order' => array('CheeseCheckin.created' => 'DESC'),
        'limit' => $limit,
        'recursive' => 2
    )
);
debug($this->Paginator->paginate('CheeseCheckin'));

结果如下所示:

array(
    (int) 0 => array(
        'CheeseCheckin' => array(
            'id' => '62',
            'created' => '2013-09-06 13:34:44',
            'comment' => 'This is a test',
            'location' => null,
            'rating' => '4',
            'short_url_hash' => '18ARMkq',
            'foursquare_id' => '40d77680f964a5205d011fe3'
        ),
        'UserAttachment' => array(
            'id' => null,
            'ext' => null,
            'name' => null,
            'path' => null
        ),
        'User' => array(
            'id' => '1',
            'username' => '...',
            'name' => 'Rob',
            'profile_image_url' => '...',
            'active' => '1',
            'email' => 'robksawyer@gmail.com',
            'private' => false,
            'attachment_id' => '616',
            'country_id' => '228',
            'state_region_id' => '48'
        ),
        'Cheese' => array(
            'id' => '379',
            'name' => 'Party In a Jar',
            'created' => '2012-10-05 16:57:04',
            'modified' => '2013-09-13 02:12:27',
            'attachment_id' => '460'
        ),
        'CheeseProducer' => array(
            'name' => 'Alsea Acre Goat Cheese',
            'created' => '2012-10-05 16:50:51',
            'id' => '43',
            'attachment_id' => null
        ),
        'Place' => array(
            'id' => null,
            'name' => null
        )
    )
)
4

1 回答 1

0

修复了问题。我只需要将 user_id、attachment_id 等添加到字段数组中。

于 2013-09-14T22:16:30.243 回答