我不知道這是不是你已經做什麼,但我認爲這已經足夠乾淨了:
function foo() {
$this->paginate['fields'] = array('field_1', 'field_2');
/* rest of the method */
}
function bar() {
$this->paginate['fields'] = array('field_3', 'field_4');
/* rest of the method */
}
如果有域,你會在所有的方法來使用,你也可以做這樣的:
var $paginate = array (
'fields' => array('always_need_this', 'also_need_this_always',)
);
function foo() {
array_push($this->paginate['fields'], 'only_in_foo', 'also_only_in_foo');
/* rest of the method */
}
function bar() {
array_push($this->paginate['fields'], 'only_in_bar', 'also_only_in_bar');
/* rest of the method */
}