Far*_*had 3 php cakephp cakephp-2.0
如何在所有查询中更改输出模型?
这意味着查询在此模型上运行,然后转到特定函数.
例如,在用户模型中,如何删除所有查询的密码字段
谢谢
将以下内容添加到您的模型中:
public function afterFind($results, $primary = false){
foreach ($results as $key => $val) {
unset($results[$key][$this->alias]['password']);
}
return $results;
}
Run Code Online (Sandbox Code Playgroud)
这应该也有效:
public function afterFind($results, $primary = false){
return Hash::remove($results, '{n}.'.$this->alias.'.password');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
74 次 |
| 最近记录: |