当用户名或密码错误时出现此错误。在正确的用户名和密码的情况下成功运行。对 .... 中的非对象调用成员函数 count()
我的代码是
public function executeLogin(sfWebRequest $request)
{
$this->form = new loginForm();
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter('login'));
if ($this->form->isValid())
{
$unm=$this->form->getValue('username');
$pwd=$this->form->getValue('password');
$q = Doctrine_Query::create()
->select('id')
->from('login')
->andWhere('username = ?', $unm)
->andWhere('password = ?', $pwd);
$q->execute();
$result = $q->fetchOne();
if ($result->count() > 0)
{
$this->getUser()->setAuthenticated(true);
$this->getUser()->addCredential('user');
$this->redirect('user/index');
}
else
{
$this->redirect('user/login');
}
}
}
}