Last active
May 15, 2020 00:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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