Is there a way to check if record exist in cake php . I know there is a function .CakePHP 2
$this->Notes->id = $id;
if (!$this->Notes->exists())
{
throw new NotFoundException(__('Invalid Notes'));
}
but by default it check with the column id
How can i check with a custom column suppose it is note_id
. my attemts are refer from here
attempt #1
if (!$this->Noteshistory->exists(['note_id'=>$id]))
{
throw new NotFoundException(__("Invalid Note "));
}
also tried to set note_id
$this->Noteshistory->note_id = $id;
if (!$this->Noteshistory->exists(['note_id'=>$id]))
{
throw new NotFoundException(__("Invalid Note "));
}
but no luck .