confused of $this in cakePHP

Posted by kwokwai on Stack Overflow See other posts from Stack Overflow or by kwokwai
Published on 2010-06-12T17:42:24Z Indexed on 2010/06/12 17:52 UTC
Read the original article Hit count: 272

Filed under:

Hi all,

I got a few lines of codes in a Model in cakePHP 1.26:

function beforeSave() { 
        $this->data['User']['pswd'] = md5($raw['User']['pswd']);              
         return true;
                         } // this beforeSave() works

The code above has been tested and it is working in my database.
Yet, I am not sure if I can understand it well,
so, I re-wrote the code in other way, and it just failed to work then.

 function beforeSave() { 
            $raw=$this->data;       
            $raw['User']['pswd'] = md5($raw['User']['pswd']);                    
             return true;
                             } // this beforeSave() failed to work

Why the second method can not work?

© Stack Overflow or respective owner

Related posts about cakephp