0
我試圖在zend框架中進行登錄,但是PDO給了我一個錯誤。 我有以下功能:'where子句'中的未知列'Array'ZF1
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))
有沒有人有一個想法,我在做什麼錯誤?
你爲什麼要用數組? – 2013-03-21 19:17:50
http://net.tutsplus.com/tutorials/php/zend-framework-from-scratch-models-and-integrating-doctrine-orm/因爲我按照這個教程了一下,他們也在這裏做 – 2013-03-21 19:23:57
你'不要使用它與$ this - > _ db_table-> update($ data,array('id =?'=> $ user_object-> id));他們有兩個參數,第一個是包含輸入字段的關聯數組 – 2013-03-21 19:31:33