User Authentication using REST API and JSON Web Tokens (JWT) – Step 5
Simple Login via Unique ID
Create a new Single Record fetch function inside the user.php file inside object folder and use the following code
public function readSingleRecord($id)
{
$query = "select * from " . $this->table . " where id= " . $id;
try {
$stmt = $this->conn->prepare($query);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
if ($stmt->rowCount() > 0) {
return $stmt;
} else {
return false;
}
} catch (PDOException $exception) {
echo json_encode(array("Single Student Read Data Error" => $exception->getMessage()));die;
}
}