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:
$conditions = array( 'User.id' => $this->Session->read('User.id'),
'User.security_key' => $this->Session->read('User.key') );
if ($this->User->hasAny($conditions)){
//do something
}
Thanks for reading the blog
0 Comment(s)