dongyishe6689 2013-09-24 20:37
浏览 11
已采纳

CakePHP - 名为'login'的字段自动转换为$ Model-> find()中的星号

I've been using Cake for quite some time, and I noticed something strange for the first time today while writing a simple search Behavior. I'm not doing anything complex, just using $Model->find()s on different Models after initializing $Model as ClassRegistry::init('Model'). Everything works great, except I have a database field named login in one of the tables. The value of this field returns as ***** for any rows that I perform a search on! This does not happen while using find()s in the Controller or Model, just in the Behavior. Below is my code:

...
...
$Model = ClassRegistry::init('User');
$fields = array('User.login', 'User.name', 'RelatedModel.field1', 'RelatedModel.field2');
$contain = array('RelatedModel');

if($searchBy === "name") {
    //some code and set $conditions
} else {
    //else some other code and set $conditions
}

$Model->Behaviors->load('Containable');
$results = $Model->find('all', array('conditions' => $conditions, 'fields' => $fields, 'contain' => $contain));
return $results;

And this is what debug() is showing:

array(
    (int) 0 => array(
        'User' => array(
            'login' => '*****',
            'name' => 'John Doe',
            'passwd' => 'a291a5c901cf51b75b6a50135ed5a04bc2e90c54',
        ),
        'RelatedModel' => array(
            'field1' => 'XXXXXXXX',
            'field2' => '7002'
        )
    )
)

The actual result should be 'login' => 'nsps_2013', as it most definitely is when I use find() in the UserController and UserModel.

  • 写回答

1条回答 默认 最新

  • donglinli2027 2013-09-24 20:51
    关注

    No, it doesn't. The Debugger class automatically sanitizes output for you, replacing the content of a bunch of different array keys with asterisks. A full list is available in the source.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站