0

I was hoping to get Cake PHP 2.x's field type mapping to change password field from a salted SHA1 hash into a varchar field, to UNHEX('$hash') in SQL, so I can store the password in the binary(20) field.

For anyone questioning why I'm doing it this way: Storing SHA1 hash values in MySQL

Currently I see no way around it than to do my own $this->User->query("INSERT INTO....");, and it would be nice to do it the cake way.

Any advise would be great!

Cheers!

1 Answer 1

0

you can try this:

public function beforeSave() {
    if (isset($this->data[$this->alias]['password'])) {
    $this->data[$this->alias]['password'] = DboSource::expression('UNHEX('. $this->data[$this->alias]['password'].')');
    $this->data[$this->alias]['test'] = 'hello';
    }
    return true;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.