php - CakePHP - field named 'login' automatically gets converted to asterisks in $Model->find() -
i've been using cake quite time, , noticed strange first time today while writing simple search behavior. i'm not doing complex, using $model->find()
s on different models after initializing $model
classregistry::init('model')
. works great, except have database field named login
in 1 of tables. value of field returns *****
rows perform search on! not happen while using find()
s in controller or model, in behavior. below code:
... ... $model = classregistry::init('user'); $fields = array('user.login', 'user.name', 'relatedmodel.field1', 'relatedmodel.field2'); $contain = array('relatedmodel'); if($searchby === "name") { //some code , set $conditions } else { //else other code , set $conditions } $model->behaviors->load('containable'); $results = $model->find('all', array('conditions' => $conditions, 'fields' => $fields, 'contain' => $contain)); return $results;
and debug()
showing:
array( (int) 0 => array( 'user' => array( 'login' => '*****', 'name' => 'john doe', 'passwd' => 'a291a5c901cf51b75b6a50135ed5a04bc2e90c54', ), 'relatedmodel' => array( 'field1' => 'xxxxxxxx', 'field2' => '7002' ) ) )
the actual result should 'login' => 'nsps_2013'
, when use find()
in usercontroller
, usermodel
.
no, doesn't. debugger class automatically sanitizes output you, replacing content of bunch of different array keys asterisks. full list available in source.
Comments
Post a Comment