Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Last active May 15, 2020 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryWonder/bb357d43eeb01489aeaf7387bcf12a03 to your computer and use it in GitHub Desktop.
Save harryWonder/bb357d43eeb01489aeaf7387bcf12a03 to your computer and use it in GitHub Desktop.
This file extends the Db Class and houses a method which is responsible for fetching a list of news from the database.
<?php
require_once(__dir__ . '/Db.php');
class DashboardModel extends Db {
/**
* @param null
* @return array
* @desc Returns an array of news....
**/
public function fetchNews() :array
{
$this->query("SELECT * FROM `db_news` ORDER BY `id` DESC");
$this->execute();
$News = $this->fetchAll();
if (count($News) > 0) {
$Response = array(
'status' => true,
'data' => $News
);
return $Response;
}
$Response = array(
'status' => false,
'data' => []
);
return $Response;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment