I am trying to improved my coding skills. I mainly work in web development. I had a "system" that I use in all my projects to fetch data from my DB to the browser. I tried an implementation of OOP, it works fine, but I dont think I did it correctly.
How can I optimized this code to make full use of an OOP design?
<?php
class DBX{
//---------------USER-----------------------------
static function GetUserByEmail($email){
$link = openlink();
$query = "SELECT * FROM users WHERE email = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "s", $email);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_assoc();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetUserByID($id){
$link = openlink();
$query = "SELECT * FROM users WHERE user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $id);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_assoc();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetUsers(){
$link = openlink();
$query = "SELECT * FROM users";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetClients(){
$link = openlink();
$l = 4;
$query = "SELECT * FROM users WHERE access_level_id = ?";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $l);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function AddUser(
$f_name,
$l_name,
$ll_name,
$email,
$access_level,
$status,
$phone,
$joinDate,
$clientNum,
$hashedPW
){
$link = openlink();
$query = "INSERT INTO users (
name,
l_name,
ll_name,
phone,
email,
status,
access_level_id,
join_date,
contract_id,
password
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param(
$stmt,
"sssssiisss",
$f_name,
$l_name,
$ll_name,
$phone,
$email,
$status,
$access_level,
$joinDate,
$clientNum,
$hashedPW
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UpdateUser($id, $userInfo){
$link = openlink();
$query = "UPDATE users SET
name = ?,
l_name = ?,
ll_name = ?,
email = ?,
access_level_id = ?,
phone = ?,
status = ?,
join_date = ?,
contract_id = ?,
password = ?
WHERE user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param(
$stmt,
"ssssisisssi",
$userInfo['name'],
$userInfo['l_name'],
$userInfo['ll_name'],
$userInfo['email'],
$userInfo['access_level_id'],
$userInfo['phone'],
$userInfo['status'],
$userInfo['join_date'],
$userInfo['contract_id'],
$userInfo['password'],
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = "false5";
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UpdateUserPasswordByID($password, $id){
$link = openlink();
$query = "UPDATE users SET
password = ?
where user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"si",
$password,
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
//---------------ACCESS LEVELS-----------------------------
static function GetAccessLevels(){
$link = openlink();
$query = "SELECT * FROM access_levels";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
//---------------Follow Ups-----------------------------
static function GetFUByUserID($id){
$link = openlink();
$query = "SELECT * FROM follow_up WHERE user_id = ? ORDER BY created_at DESC";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $id);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function AddFu($targetID, $senderID, $type, $message){
$link = openlink();
$date = date("Y-m-d H:i:s");
$query = "INSERT INTO follow_up (user_id, created_by, created_at, type, message) VALUES (?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "iisis", $targetID, $senderID, $date, $type, $message);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
//-------REPURPUSING Pool
//---------------USER-----------------------------
static function QuickAddUser($email, $f_name, $l_name, $ll_names, $hashedPW){
$link = openlink();
$status = 1;
$accessLevel = 8;
$query = "INSERT INTO users (email, f_name, l_name, ll_name, password, status, access_level_id)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param(
$stmt,
"sssssii",
$email,
$f_name,
$l_name,
$ll_names,
$hashedPW,
$status,
$accessLevel
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetUserByUsername($username){
$link = openlink();
$query = "SELECT * FROM users WHERE username = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "s", $username);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_assoc();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetUsersByNames($string){
$link = openlink();
$string = "%".$string."%";
$query = "SELECT * FROM users WHERE f_name LIKE ? OR l_name LIKE ? OR ll_name LIKE ?";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "sss", $string, $string, $string);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetStudentsByGroupID($groupID){
$link = openlink();
$query = "SELECT * FROM users WHERE group_id = ? ORDER BY l_name DESC";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $groupID);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetStudentsBySchoolYearID($yearID){
$link = openlink();
$query = "SELECT * FROM users WHERE grado_id = ? ORDER BY l_name DESC";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $yearID);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetFamilyByChildID($userID){
$link = openlink();
$query = "SELECT * FROM family_student WHERE student_id = ?";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $userID);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetChildrenByFamilyID($userID){
$link = openlink();
$query = "SELECT * FROM family_student WHERE family_member_id = ?";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $userID);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetUserByIDArray($id){
$link = openlink();
$query = "SELECT * FROM users WHERE user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $id);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetUsersByAccessLevel($accessLevel){
$link = openlink();
$query = "SELECT * FROM users WHERE access_id = ? ORDER BY l_name DESC";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $accessLevel);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function linkToStudentByTargetUserID($id, $studentID){
$link = openlink();
$query = "INSERT INTO family_student (student_id, family_member_id) VALUES (?, ?)";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"ii",
$studentID,
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UnlinkStudent($id, $studentID){
$link = openlink();
$query = "DELETE FROM family_student WHERE student_id = ? AND family_member_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"ii",
$studentID,
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function AddStudentToGroup($groudID, $studentID){
$link = openlink();
$query = "UPDATE users SET
group_id = ?
where user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"ii",
$groudID,
$studentID
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UpdateUserPhotoByID($photoLoc, $id){
$link = openlink();
$query = "UPDATE users SET
profile_photo = ?
where user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"si",
$photoLoc,
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UpdateUserStatusByID($id, $status){
$link = openlink();
if ($status) {
$tempStatus = 1;
} else {
$tempStatus = 0;
}
$query = "UPDATE users SET
status = ?
where user_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"ii",
$tempStatus,
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
//---------------SCHOOL GRADE YEARS-----------------------------
static function AddSchoolYear($yearName){
$link = openlink();
$status = 1;
$query = "INSERT INTO grados ( name, status) VALUES (?, ?)";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "si", $yearName, $status);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetSchoolYearGrades(){
$link = openlink();
$query = "SELECT * FROM grados";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_all();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function GetSchoolYearByID($id){
$link = openlink();
$query = "SELECT * FROM grados WHERE grados_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "i", $id);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_assoc();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UpdateSchoolYear($id, $year){
$link = openlink();
$query = "UPDATE grados SET
name = ?
WHERE grados_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"si",
$year['name'],
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
static function UpdateSchoolYearStatusByID($id, $status){
$link = openlink();
if ($status) {
$tempStatus = 1;
} else {
$tempStatus = 0;
}
$query = "UPDATE grados SET
status = ?
where grados_id = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
} else {
mysqli_stmt_bind_param(
$stmt,
"ii",
$tempStatus,
$id
);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
//---------------ACCESS LEVELS-----------------------------
static function AddAccessLevel($yearName){
$link = openlink();
$query = "INSERT INTO acess_levels (name) VALUES (?)";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "s", $yearName);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$finalTest = true;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
}
//open link
include 'dbConnect.inc.php';
//closing link
function closeLink($stmt, $link){
mysqli_stmt_close($stmt);
mysqli_close($link);
}
//date("Y-m-d H:i:s")
?>
As you can see I repeat most of the code over and over, I think I could do one method for each CRUD and then somehow just pass the differences... any ideas??
1 Answer 1
1. This is not OOP
Ask yourself one simple question: what would happen if you remove words "class", "DBX" and "static" from your code?
Nothing.
Nothing would happen. It would continue to work. Because your code is essentially procedural. There is not a hint of OOP, other than a Halloween costume.
An object is not a collection of functions. It's a collection of functions and variables working together
.
Moreover, OOP is not about stuffing some functions and variables into a single entity either. OOP is about the object interconnection. Your code becomes OOP only when your objects talk to each other, use each other, pass information from each other.
2. At this stage, you can not and should not try to use OOP
- First, there are other, much more pressing matters.
- Besides, Object Oriented Programming is a helluva complex matter. Nobody can learn it from a post on Stack Overflow. It takes years to grasp. An only after you get some experience with procedural and feel its limitations.
- After all, your goal is a more organized code which you confused with OOP. I can assure you, this code could be made 10 times more organized without any OOP.
3. Learn the object syntax first
You have to realize that OOP stands for writing classes only. Whereas using existing classes in your procedural code is just about a slightly different syntax. An incomparably simpler matter that you can grasp in 5 minutes. An mysqli is a perfect example that can demonstrate the difference. Instead of writing too werbose and uselessly elaborate code like this
mysqli_stmt_bind_param($stmt, "s", $email);
you are just taking the $stmt
part, then add an arrow, ->
and then add a meaningful function name without repeating words stmt and mysqli over and over again.
$stmt->bind_param("s", $email);
see, almost 2 times shorter!
all you need to know that each object can contain a variable (called a property), a function (called a method) and a constant (called a class constant). And you call them as follows
$obj->property; // similar to a variable, no braces
$obj->method($param); // similar to a function, with or without parameters
CLASS::CONSTANT; // similar to regular constant but prefixed with class name and ::
4. Start organizing your code without OOP
There are many techniques, let's see what we can do. Fist of all, having functions like yours is the right move. For the moment just have them as functions, not static methods. but they can be improved.
5. Fight the repetitions
As you correctly noticed, your current code repeats itself over an over. When you see a repetition, it's time to introduce a function. Definitely, all the code required to run a single mysql query is asking to be encapsulated in a function. Luckily, I already have one already made, exactly for the purpose:
function prepared_query($mysqli, $sql, $params, $types = "")
{
$types = $types ?: str_repeat("s", count($params));
$stmt = $mysqli->prepare($sql);
$stmt->bind_param($types, ...$params);
$stmt->execute();
return $stmt;
}
You may read the detailed description in my article, Mysqli helper function.
Just compare the two methods
static function GetUserByEmail($email){
$link = openlink();
$query = "SELECT * FROM users WHERE email = ? LIMIT 1";
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, $query)) {
//return false if there was an error
return false;
}else {
mysqli_stmt_bind_param($stmt, "s", $email);
if (mysqli_stmt_execute($stmt)) {
$result = $stmt->get_result(); // get the mysqli result
$resultArray = $result->fetch_assoc();
$finalTest = $resultArray;
} else {
$finalTest = false;
}
}
closeLink($stmt, $link);
return $finalTest;
}
vs
function GetUserByEmail($link, $email){
$link = openlink();
$query = "SELECT * FROM users WHERE email = ? LIMIT 1";
$stmt = prepared_query($link, $query, $email);
$result = $stmt->get_result();
return $result->fetch_assoc();
}
Whoops! Three times less code!
6. Learn very important basic concepts
- A database connection should be made only once. Create a db link at the beginning and then pass to your functions as a parameter
- Learn the proper error reporting. Simply returning false in case of error is absolutely not the way to go. An error must be reported to you, so you'll be able to fix it. the link is to my article that will give you an idea.
static
methods must be used with caution. For the time being avoid them completely- Consider formatting your code according to a standard
7. Eventually, you could begin to learn OOP
- First, you can group methods that belong to a single table, into distinct classes.
- When you notice that some methods in these classes have identical code, but only differ by the table name and the set of fields, then you can create a prototype (abstract) class with such methods that use class variables that hold the table and field names, and then extend your classes from it.
Here is an example of such a basic OOP I am talking about. Using this approach, you will have a User
class with add()
and get()
methods without the need of writing AddUser()
and GetUser()
at all! That will be OOP.
mysqli
functions/methods. Right now it is inconsistent. \$\endgroup\$$this
. \$\endgroup\$