Skip to content

Latest commit

 

History

History
53 lines (47 loc) · 843 Bytes

README.md

File metadata and controls

53 lines (47 loc) · 843 Bytes

SmoothSQL

Description

SmoothSQL is a lightweight PHP library designed to simplify reusable MySQL database operations using prepared statements.

Example on how to Use

  • Insert
# Here is an example with inserting user register
$db->insert("users", [
  "username" => $username,
  "email" => $email,
  "hashed_password" => $hashedPass
]);
  • Fetch
# Here is an example of fetching user logins
$data = $db->fetch(
  "users",
  "*",
  "email = ?",
  [$email]
);
  • Delete
# Here is an example of deleting messages
if (isset($_POST["deleteBtn"])) {
  $db->delete(
    "messages",
    "id = ?",
    [$_POST["msg_id"]]
  );
}
  • Update
# Here is an example of updating user info
$db->update(
  "users",
  [
    "username" => $newUsername,
    "email" => $newEmail
  ],
  "id = ?",
  [$userId]
);