Skip to content

Instantly share code, notes, and snippets.

Avatar
🇳🇬
I am that software developer that you cannot sideline. I am <harrywonder/>

Ilori stephen harryWonder

🇳🇬
I am that software developer that you cannot sideline. I am <harrywonder/>
View GitHub Profile
@harryWonder
harryWonder / Db.php
Last active May 15, 2020
A Db Class which provides a decent abstraction layer for making database operations.
View Db.php
<?php
class Db {
protected $dbName = 'learning_dollars_db'; /** Database Name */
protected $dbHost = 'localhost'; /** Database Host */
protected $dbUser = 'root'; /** Database Root */
protected $dbPass = ''; /** Databse Password */
protected $dbHandler, $dbStmt;
/**
* @param null|void
@harryWonder
harryWonder / Db.php
Last active May 15, 2020
A Db Class which provides a decent abstraction layer for making database operations.
View Db.php
<?php
class Db {
protected $dbName = 'learning_dollars_db'; /** Database Name */
protected $dbHost = 'localhost'; /** Database Host */
protected $dbUser = 'root'; /** Database Root */
protected $dbPass = ''; /** Databse Password */
protected $dbHandler, $dbStmt;
/**
* @param null|void
@harryWonder
harryWonder / LoginModel.php
Last active May 15, 2020
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
View LoginModel.php
<?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
@harryWonder
harryWonder / RegisterModel.php
Last active May 15, 2020
This file extends the Db.php Class and provides two methods for creating a new user and fetching a new user.
View RegisterModel.php
<?php
require_once(__dir__ . '/Db.php');
class RegisterModel extends Db {
/**
* @param array
* @return array
* @desc Creates and returns a user record....
**/
public function createUser(array $user) :array
@harryWonder
harryWonder / DashboardModel.php
Last active May 15, 2020
This file extends the Db Class and houses a method which is responsible for fetching a list of news from the database.
View DashboardModel.php
<?php
require_once(__dir__ . '/Db.php');
class DashboardModel extends Db {
/**
* @param null
* @return array
* @desc Returns an array of news....
**/
public function fetchNews() :array
@harryWonder
harryWonder / Controller.php
Created May 10, 2020
This file acts as the base controller for other controllers in the controllers folder.
View Controller.php
<?php
session_start();
class Controller { }
?>
@harryWonder
harryWonder / Dashboard.php
Last active May 15, 2020
This file houses a class which loads in some dependencies from the DashboardModel.php file.
View Dashboard.php
<?php
require_once(__dir__ . '/Controller.php');
require_once('./Model/DashboardModel.php');
class Dashboard extends Controller {
public $active = 'dashboard'; //for highlighting the active link...
private $dashboardModel;
/**
* @param null|void
@harryWonder
harryWonder / Login.php
Last active May 15, 2020
This file loads in the LoginModel Controller and it also extends the base controller.
View Login.php
<?php
require_once(__dir__ . '/Controller.php');
require_once('./Model/LoginModel.php');
class Login extends Controller {
public $active = 'login'; //for highlighting the active link...
private $loginModel;
/**
@harryWonder
harryWonder / Register.php
Last active May 15, 2020
This class extends the base controller and loads in the RegisterModel as a dependency
View Register.php
<?php
require_once(__dir__ . '/Controller.php');
require_once('./Model/RegisterModel.php');
class Register extends Controller {
public $active = 'Register'; //for highlighting the active link...
private $registerModel;
/**
* @param null|void
@harryWonder
harryWonder / Logout.php
Last active May 15, 2020
This file houses a logout class which extends the base controller. This class destroys the application session and performs an http redirect.
View Logout.php
<?php
require_once(__dir__ . '/Controller.php');
class Logout extends Controller {
/**
* @param null|void
* @return null|void
* @desc Destroys the application session and redirects to the login page...
**/