ratingthomas/sqlmanager

A small script that lets you easily interact with your mysql database

2.0.1 2024-10-15 14:15 UTC

This package is not auto-updated.

Last update: 2025-06-24 17:51:21 UTC


README

SQLManager is a small script that lets you easily interact with your mysql database.

Features

  • Easy to use
  • Secure (SQL Injection prevention)
  • Simple and fast

Installation

  1. Download the latest release with composer or from the releases page.
composer require ratingthomas/sqlmanager
  1. Put the script somewhere in your project.
  2. Add the following code:
<?php
  include 'path/to/SQLManager.php';
  use Ratingthomas\SQLManager\SQL;
  $sql = new SQL\SQL();
?>

How to use

Here i will explain how you can use the script.

Connect to Database

$sql->connect("db_name", "db_username", "db_password", "db_name");
Parrameter Details Example
db_host The database host. localhost
db_username Username root
db_password Password admin
db_name The name of the database test

Get data from the dabatase

Example 1

$result = $sql->query("SELECT * FROM users WHERE userid = ? AND user_type = ?", ['1', 'superadmin'], true);
print_r($result);

Example 2

$result = $sql->query("SELECT * FROM users", []);
print_r($result);
Parrameter Details Example Type Required Can be empty
query The sql query SELECT * FROM test; String true False
options If you have a where statement [$param1, $param2] Array true true
array_push Make the array Multidimensional true boolean false true
no_result Set this to true if the sql query has no return falue true boolean false true

Get the connection info.

$sql->displayconnection()