0

我正在尝试在 zend 框架中进行登录,但 PDO 给了我一个错误。我有以下功能:

public function isCorrectLogin (Application_Model_User $user){

    $row = $this->_db_table->fetchRow(
                $this->_db_table
                     ->select()
                     ->where( array ('email = ?' => $user->email,
                                     'password = ?' => sha1(SALT.$user->password)))
                           );

    if(empty($row)){
        return false;
    }
    return true;                
}

在我的控制器中,我使用此功能:

$oUserActions = new Application_Model_UserMapper();

            $user = new Application_Model_User();
            $user->email = $_REQUEST['email'];          
            $user->password = $_REQUEST['password'];

            if($oUserActions->isCorrectLogin($user)){                   
                echo 'validated';                   
            }

我收到此错误:

Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Array' in 'where clause'

Stack trace:

#0 C:\webserver\htdocs\photo\library\Zend\Db\Statement.php(303): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\webserver\htdocs\photo\library\Zend\Db\Adapter\Abstract.php(480): Zend_Db_Statement->execute(Array)
#2 C:\webserver\htdocs\photo\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array)
#3 C:\webserver\htdocs\photo\library\Zend\Db\Table\Abstract.php(1575): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select))
#4 C:\webserver\htdocs\photo\library\Zend\Db\Table\Abstract.php(1437): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select))
#5 C:\webserver\htdocs\photo\application\models\UserMapper.php(49): Zend_Db_Table_Abstract->fetchRow(Object(Zend_Db_Table_Select))
#6 C:\webserver\htdocs\photo\application\controllers\LoginController.php(31): Application_Model_UserMapper->getUserLogin(Object(Application_Model_User))

有谁知道我做错了什么?

4

1 回答 1

3

试试这个。为什么要使用数组。

$select->where(
        $db->quoteInto('email = ?', => $user->email) . ' AND ' . $db->quoteInto('password = ?', sha1(SALT.$user->password))
    );
    // $db is your instance of Zend_Db_Adapter_*
    // You can get it from a Zend_Db_Table_Abstract 
    //subclass by calling its getAdapter() method
于 2013-03-21T19:34:11.173 回答