Database check using ORM not working properly

Hi there... Trying to do this for my login: code $email = $this -> request -> getPost('email'); $password = $this -> request -> getPost('password');

        $user = User::find(
            [
                "conditions" => "email = :email: AND password = :password:",
                "bind" == [
                    'email'     => $email,
                    'password'     => sha1($password)
                ]
            ]);
        //$count = count($user);
        if($user === false){
            $this->flashSession->message('dark', "Your details are incorrect. Please check and try again");
            $this->dispatcher->forward(
            [
                'controller'    => 'auth',
                'action'        => 'index'
            ]);
        }
        else{
            $this->flashSession->message('success', "Welcome, ".$user->fullname ."Count: ".$count);
            $this->dispatcher->forward(
            [
                'controller'    => 'auth',
                'action'        => 'index'
            ]);
        }

There's only one record in the db. However, regardless of the details I insert (correct or not, $user is never null / false. Please correct me if I made a mistake. Thanks.

Hi @core2work the mistake is very simple. You have to use User::findFirst() insteandof User::find()

Good luck

Thanks. However, I still get the same result. If I use

print_r($users);
die();

I can see the ResultSet object with the details of only the first record whether it matches the criteria or not.

Let me go through my configs and see if I made a mistake somewhere...