开发者

cakephp Counter cache in nested model

i have nested model structure

id

parent_id

counter

name开发者_StackOverflow中文版

how to use automated counter cache


Define it in the relationship definition.

<?php

class YourModel extends AppModel {

    var $belongsTo = array(
        'ParentModel' => array(
            'foreignKey' => 'your_model_id',
            'className' => 'ParentModel',
            'counterCache' => 'counter'
            )
        )
    );
}
?>

Where 'counter' is the field in your table that contains the count.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜