2011-03-15 88 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。

您是否阅读过任何手册,或是按照教程进行操作?好像你甚至不知道发生了什么事情?