Last active
May 15, 2020 00:11
-
-
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.
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 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