0

I have something like this:

$data = array('username' => 'John', 'password' => 'john123');
$table = new Zend_Db_Table('users');
$table->insert($data);

But I want it to include a hashing function to the password, so the sql is something like this:

INSERT INTO `users` (`username`, `password`) VALUES ('John', PASSWORD('john123'));

How can I do that, elegantly?

1 Answer 1

1
$data = array('username' => 'John', 'password' => new Zend_Db_Expr('SHA1(john123)');
Sign up to request clarification or add additional context in comments.

2 Comments

May also work without the object in some cases (like in where() function or select statement - Zend is looking for brackets there to convert the value into function...).
I ended up having to do Zend_Db_Expr('SHA1('.$db->quote('john123').')')

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.