1

我想在 CakePHP 2.x 中使用 counterCache 更新两个字段。我试过这段代码:

public $belongsTo = array(
    'Table2' => array(
        'className' => 'Table2',
        'counterCache' => 'downvote_count',
        'counterScope' => array('Table2.id' => 0)
    ),
    'Table2' => array(
        'className' => 'Table2',
        'counterCache' => 'upvote_count',
        'counterScope' => array('Table2.id' => 2)
    )
);

..但它只更新最后一个字段。

4

1 回答 1

1
public $belongsTo = array(
    'Table2' => array(
        'className' => 'Table2',
        'counterCache' => array(
            'downvote_count' => true,
            'upvote_count' => true
        )
    )
);
于 2012-05-19T00:20:56.193 回答