Check Record exists in database

$user = $this->Users->newEntity();
if ($this->request->is(‘post’)){
$number = $this->request->data[‘number’];
$num = $this->Users->findByEmail($number)->select([‘number’])->hydrate(false)->first();

			$user = $this->Users->patchEntity($user, $this->request->data);
			echo "1";
			echo "There is another...";
    $this->set('_serialize', ['user']);

You didn’t ask a question, but it looks like you are trying to validate that a form field corresponding to a database column contains a unique value. You could simply add a custom validation to the UsersTable.php $validator:

->add(‘email’, [
‘unique’ => [
‘rule’ => ‘validateUnique’,
‘provider’ => ‘table’,
‘message’ => ‘This email is already associated with an active account’