Hi Dhileepen,

I don't think you'll need to build your own query to validate.


function validateLogin($data)
    {
        $user = $this->find(array('username' => $data['username'],
'password' => $data['password']), array('id', 'username'));
        if(empty($user) == false)
            return $user['User'];
        return false;
    }


When I use find method, I like to pass all data like this: (assuming that
you just want id and username fields).

function validateLogin($data)
{
    $user = $this->find('first',array(
        'fields' => array('id', 'username'),
        'conditions' => array('username = ' => $data['username'], 'password
= ' => $data['password']),
        )
    );

    if(empty($user) == false)
        return $user['User'];
    return false;
}


In find method, I passed an associated array, with the fields and conditions
for my search. the 'first' argument means that I just want the first result.



Atenciosamente,
Thiago Elias.





2009/7/17 Andreas Derksen <[email protected]>

>
> Hi,
> its much simpler, follow the steps on the cookbook.
> http://book.cakephp.org/complete/172/Authentication
>
> greets
> Andreas
>
>
> Dhileepen Chakravarthy schrieb:
> > Thanks for your reply. I am new for cakePHP. I find i did a mistake in
> >
> > function validateLogin($data)
> >     {
> >         $user = $this->find(array('username' => $data['username'],
> > 'password' => $data['password']), array('id', 'username'));
> >         if(empty($user) == false)
> >             return $user['User'];
> >         return false;
> >     }
> >
> > how do i wrote my query in this function validateLogin()
> > "select username from users where username = $data['username'] and
> > password=$data['password']"
> >
> > Regards,
> > Dhileepen
> >
> >
> >
> > >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to