2011-03-15 82 views
0

我們對一個項目使用Zend Framework和Doctrine。我已經使用Doctrine ORM安裝了應用程序。ZF /學說問題

當我回顯語句時,它只打印「FROM User u WHERE u.username =?」

什麼是「Doctrine_Query :: create()」?

任何圖書館是必需的?

public function loginAction(){  
    $error_messages = array(); 

    $params = $this->_request->getParams(); 
    if($_POST) 
    { 
     $params = $this->_request->getParams(); 

     $username = $params['username']; 
     $password = $params['password']; 

     $query = Doctrine_Query::create() 
      ->from('User u') 
      ->where('u.username = ?',$username); 
     echo $query; 
     exit; 
     $user = $query->execute()->getFirst(); 

     //Authentication ! 
     $authexAdapter = new Application_Auth_exAdapter($user,$password);   
     $authResult = Zend_Auth::getInstance()->authenticate($authexAdapter); 

     if(!$authResult->isValid()){ 
      $error_messages = $authResult->getMessages(); 
     } else { 
      //sucess! 

        $this->_redirect('account/setup'); 

     } 
    } 
    $this->view->error_messages = $error_messages; 
}  
+0

可能是http://stackoverflow.com/questions/2772902/symfony-and-doctrine-1-2-2-how-can-i-get-the-sql-clause-of-a-doctrine -query-obje – akond 2011-03-15 07:25:35

+0

代碼中的'exit;'肯定會阻止它在'echo $ query;'行後面顯示任何東西。 – 2011-03-15 17:18:28

回答

1
Doctrine_Query::create() 

它創建將運行的找到你的對象的查詢。當回顯對象時,它會打印創建的字符串查詢。

任何庫是必需的?

那麼,學說ORM。

您是否閱讀過任何手冊,或是按照教程進行操作?好像你甚至不知道發生了什麼事情?