From 510a20d55a92a15f177f8fe582acb194d1a24efa Mon Sep 17 00:00:00 2001 From: MHEN2606 <matthew.mahendra@gmail.com> Date: Thu, 9 Nov 2023 21:09:54 +0700 Subject: [PATCH] feat: Get All Scholarship API for REST --- api/scholarship/getAllScholarships.php | 14 ++++++++++++++ app/models/scholarship.php | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 api/scholarship/getAllScholarships.php diff --git a/api/scholarship/getAllScholarships.php b/api/scholarship/getAllScholarships.php new file mode 100644 index 0000000..78ed79a --- /dev/null +++ b/api/scholarship/getAllScholarships.php @@ -0,0 +1,14 @@ +<?php +require_once '../../app/core/App.php'; +require_once '../../app/core/Database.php'; +require_once '../../app/models/Scholarship.php'; +require_once '../../config/config.php'; + +$scholarship = new Scholarship(0,0); + +$data = $scholarship->getAllScholarshipREST(); + +$results = mysqli_fetch_all($data, MYSQLI_ASSOC); + +echo json_encode($results); +?> \ No newline at end of file diff --git a/app/models/scholarship.php b/app/models/scholarship.php index 92d153c..e135be7 100644 --- a/app/models/scholarship.php +++ b/app/models/scholarship.php @@ -189,6 +189,15 @@ class Scholarship } + public function getAllScholarshipREST(){ + $query = "SELECT user_id, scholarship_id, title, description, short_description, coverage, contact_name, contact_email + FROM $this->table"; + $stmt = $this->db->setSTMT($query); + mysqli_stmt_execute($stmt); + $result = mysqli_stmt_get_result($stmt); + return $result; + } + public function getAllScholarship($offset, $limit){ $query = ''; $stmt = null; -- GitLab