Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Last active May 15, 2020 00:16
Show Gist options
  • Save harryWonder/08b5c5f77270f2d193b07d8a64582b96 to your computer and use it in GitHub Desktop.
Save harryWonder/08b5c5f77270f2d193b07d8a64582b96 to your computer and use it in GitHub Desktop.
A LoginModel class which searches for a user based on the user email address and returns an array with a status and data key which determines the result of the search
<?php
require_once(__dir__ . '/Db.php');
class LoginModel extends Db {
/**
* @param string
* @return array
* @desc Returns a user record based on the method parameter....
**/
public function fetchEmail(string $email) :array
{
$this->query("SELECT * FROM `db_user` WHERE `email` = :email");
$this->bind('email', $email);
$this->execute();
$Email = $this->fetch();
if (empty($Email)) {
$Response = array(
'status' => true,
'data' => $Email
);
return $Response;
}
if (!empty($Email)) {
$Response = array(
'status' => false,
'data' => $Email
);
return $Response;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment