开发者

Problem with sfValidatorDoctrineChoice

开发者 https://www.devze.com 2023-04-01 12:08 出处:网络
The code is: $query = Doctrine_Core::getTable(\'Users\')->createQuery(\'u\') ->select(\'u.email\')

The code is:

$query = Doctrine_Core::getTable('Users')->createQuery('u')
        ->select('u.email')
        ->where('u.username = ?', $this->getRequest()->getCookie('vL_username'))
        ->andWhere('u.password = ?', md5($editprofile['password']));
$this->form->setValidators(array(
    'password' => new sfValidatorDoctrineChoice(array(
                'model'=>'Users',
                'column'=>'password',
                'query'=>$query,
                ), array(
                'invalid' => 'The password is wrong.',
                'required' => 'Required',
                )
    ),
));

But it's not working. It automatically adds AND WHERE password = 'whatever the inputed value is (unencrypted)'

The idea is that I need to encrypt using md5 the input value开发者_开发问答 before checking against the record in the db. If I delete 'column'=>'password', and only leave the $query, it automatically adds the inputed value as id! (Which is the primary key of the table).

In my case I don't need sfValidatorDoctrineChoice to write the query, just to use mine to check if a record exists with the given parameters. How can I do this?


The solution I found and works:

$editprofile=$request->getParameter('editprofile');
$editprofile['password']=md5($editprofile['password']);
$request->setParameter('editprofile', $editprofile);

Maybe there's a better one.

0

精彩评论

暂无评论...
验证码 换一张
取 消