PHPackages                             tylersriver/php-simple-sql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. tylersriver/php-simple-sql

ActiveLibrary[Database &amp; ORM](/categories/database)

tylersriver/php-simple-sql
==========================

A simple self managed wrapper for MySQLi in PHP

2.3.3(7y ago)023MITPHPPHP ^7.1

Since Sep 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tylersriver/PHPSimpleSQL)[ Packagist](https://packagist.org/packages/tylersriver/php-simple-sql)[ RSS](/packages/tylersriver-php-simple-sql/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (1)Versions (8)Used By (0)

1 SimpleSQL
===========

[](#1-simplesql)

A simple self managed wrapper for MySQLi in PHP. This class is useful for small websites with a single DB connection.

1.1 Why?
--------

[](#11-why)

I have been making some small personal websites and I wanted a way to minimize the amount of code it took to use MySQLi and still have the security to help prevent sql injection. I have reduced it to a single function call with this class.

1.2 Features
------------

[](#12-features)

- Singleton maintains single connection
- Simple to use
- single flexible query function
- It runs any query (Select, Update, Delete, Insert) and it will parameterize the query
- Inserts return the insert id

1.3 Example
-----------

[](#13-example)

### 1.3.1 Defining MySQL Server Constants

[](#131-defining-mysql-server-constants)

These constants will be used by the SQL class

```
define("MYSQL_SERVER", "localhost");
define("MYSQL_USER", "testUser");
define("MYSQL_PASSWORD", "test");
define("MYSQL_DB", "test");
```

### 1.3.2 Using the class

[](#132-using-the-class)

```
