Skip to content
Snippets Groups Projects
user.php 933 B
<?php

class User {
    function getAllUser(){
        $con = mysqli_connect('localhost','root','','projekers');
        mysqli_select_db($con, 'projekers');
        $sql = "SELECT * FROM user";
        $result = mysqli_query($con, $sql);
        mysqli_close($con);
        return $result;
    }

    function getUserByUsername($username){
        $con = mysqli_connect('localhost','root','','projekers');
        mysqli_select_db($con, 'projekers');
        $sql = "SELECT * FROM user WHERE username='" . (string)$username . "'";
        $result = mysqli_query($con, $sql);
        mysqli_close($con);
        return $result;
    }

    function getUserById($id){
        $con = mysqli_connect('localhost','root','','projekers');
        mysqli_select_db($con, 'projekers');
        $sql = "SELECT * FROM user WHERE id=" . $id;
        $result = mysqli_query($con, $sql);
        mysqli_close($con);
        return $result;
    }
}