<?php

class User {
    public $con;

    public function __construct($conn){
        $this->con = $conn;
    }

    public function getById($id){
        $quest = array();
        $sql = "SELECT * FROM users WHERE id = ".$id."";

        $result = $this->con->query($sql);

        if ($result && $result->num_rows > 0) {
            // output data of each row
            while($row = $result->fetch_assoc()){
                array_push($quest, $row);
            }
            return json_encode($quest);
        }else{
            return false;
        }
    }

    public function getAllUsers(){
        $quest = array();
        $sql = "SELECT * FROM users";

        $result = $this->con->query($sql);

        if ($result->num_rows > 0) {
            // output data of each row
            while($row = $result->fetch_assoc()){
                array_push($quest, $row);
            }
            return json_encode($quest);
        }
    }
}