Patrick Vd Pols
Patrick Vd Pols

Reputation: 5

Unknown column 'Array' in 'where clause' ZF1

i'm trying to make a login in zend framework, but PDO is giving me an error. I have the following function :

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;                
}

In my controller i use this function :

$oUserActions = new Application_Model_UserMapper();

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

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

Im getting this error :

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))

Does anyone have an idea what i am doing wrong?

Upvotes: 0

Views: 688

Answers (1)

Birju Shah
Birju Shah

Reputation: 1220

Try this. Why are you using an array.

$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

Upvotes: 3

Related Questions