Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check if record exists in Cakephp ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.12k
    Comment on it

    Hello friends, welcome to findnerd. I am writing this blog which will let you know how to check if record exists in Cakephp 2.* . The best way to do is to use Model::hasAny

    hasAny( array $conditions null ) : Returns true if a record that meets given conditions exists.

    Usage:

    1. $conditions = array( 'User.id' => $this->Session->read('User.id'),
    2. 'User.security_key' => $this->Session->read('User.key') );
    3. if ($this->User->hasAny($conditions)){
    4. //do something
    5. }

     

    Thanks for reading the blog

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: