2013-10-31 4 views
0

사용자 이름이나 암호가 잘못되었을 때이 오류가 발생했습니다. 올바른 사용자 이름과 암호를 사용하여 성공적으로 실행하십시오. 에 ....비 객체에서 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'); 
      } 
     } 
    } 
} 
+0

는, 스택 백 트레이스를 게시하시기 바랍니다. – Jacobson

+0

symfony1.4의 새로운 기능입니다. 그래서 내가 원하는 것을 알지 못합니다. – hemsbhardiya

답변

2

$ 값이 NULL 값을 가지고 결과입니다. 먼저 확인해야합니다. 의는 다음에 조건을 변경할 수 있습니다 :

if ($result && $result->count() > 0) {...} 

또는

if ($result) {...} 
+0

thanks romik. 좋은 일. – hemsbhardiya

관련 문제