PHPackages                             brazucaz/php\_database - 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. brazucaz/php\_database

AbandonedArchivedLibrary

brazucaz/php\_database
======================

A full management system for MySQL databse control

19PHP

Since Dec 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/brazucaz/php_database)[ Packagist](https://packagist.org/packages/brazucaz/php_database)[ RSS](/packages/brazucaz-php-database/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

php\_database - PHP Class
=========================

[](#php_database---php-class)

A full management system for MySQL databse control class. The code is inspired from a Github Gist I found by [jonashansen229](https://gist.github.com/jonashansen229/4534794).

I have extended the Class to allow for SQL commands to `SELECT`, `INSERT`, `UPDATE`, and `DELETE`. All fully modular, so that developers may have an easy time simply getting the code and plug it in straight to what they are working on. I also do not claim any rights or responsability over the code. Use it at your own risk!

---

### Getting started

[](#getting-started)

Now, as I have mentioned above, I made this to be as easy for the user as I possibily could. So let's get started: assuming you are already using Composer, you can get the project by adding it to the `required` section of your `composer.json`.

```
composer require brazucaz/php_database dev-master

```

Or you can download the class from the `src` folder; you can include it in your project however you feel fit.

Once you have the class included in your project call it by simply using:

```
$db = database::get_instance();
$mysqli = $db->get_connection();
```

Now you are able to get started using the functions within the class.

---

### Functions

[](#functions)

As I mentioned above, I have extended the Class to manage the MySQL database by creating 4 separate functions which are useful for common queries used in MySQL and PHP. The functions are as follows:

- Select
- Insert
- Update
- Delete

#### SELECT

[](#select)

The most common, perhaps, would be to `SELECT` content from databases, and surely enough I have. The Select function has two parameters, `$fields`, `$table`.

`$fields`: will ask for a single dimention array with the names of each column

`$table`: of course, simply the table name as a simple string

```
$fields = array('id', 'field1', 'field2', '...');
$table = "table_name";
```

Once you have the two setup simply call back the function

```
$db = database::get_instance();
$mysqli = $db->get_connection();

$select = $db->select($fields, $table);
```

This will return a multidimentional array setup as:

```
'Column' => 'Row'

```

I will allow for you to decide how you want to use that information.

### Insert

[](#insert)

Another common action with MySQL databases is to `INSERT` a new row into the database. Thinking of that, I have added the `insert()` function.

This function also has two parameters which are mandatory and one non-mandatory `insert($content_array, $table, $extra = '')`; `$extra` would play in if you have any extra parameters for your query such as, `WHERE`, `LIMIT`, `ORDER BY`, etc. Now here's the catch, `$content_array` is different from `$fields` from the Select function.

`$content_array` is a 2d array setup as a `Key => Value` array. And `$table` --- you guessed it.

```
$content_array = array(
    'Column' => 'Value',
    'Column' => 'Value',
    'Column' => 'Value'
);

$table = 'table_name';
```

Once you have setup the values you are ready to call back the function:

```
$db = database::get_instance();
$mysqli = $db->get_connection();

$insert = $db->insert($content_array, $table);
```

If you have any query parameters that you need to add, send them as a string:

```
$exta = 'ORDER BY id ASC LIMIT 1';

$insert = $db->insert($content_array, $table, $extra);
```

The return value is a 2d array that is setup as:

```
array (
    'is_error' => 'success',
    'message' => 'Message goes here'
)
```

Calling the array - just use the variable + array param. For example: `$insert['message'];`

### Update

[](#update)

The update function is extremely similar to `insert`. The only difference when calling the function, is that `update` has one extra parameter - the `$id`.

So instead of explaining how the variables and results work I will show you how to call the function:

```
$db = database::get_instance();
$mysqli = $db->get_connection();

$update = $db->update($id, $content_array, $table);
```

The return value is the same as `insert`.

### Delete

[](#delete)

Finally, the `delete` function; this one is straight forward and simple; the only two parameters are `$id`, and `$table`. This will delete the column and respond with our old 2d array for messages.

```
$db = database::get_instance();
$mysqli = $db->get_connection();

$delete = $db->delete($id, $table);
```

This will return whether there was a success or an error.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/347e08bdb9dd20eb62a3668afc51e4dc4669f184d1a14aa55497a29aeafc2a9c?d=identicon)[brazucaz](/maintainers/brazucaz)

---

Top Contributors

[![samuel-fonseca](https://avatars.githubusercontent.com/u/17728473?v=4)](https://github.com/samuel-fonseca "samuel-fonseca (17 commits)")

### Embed Badge

![Health badge](/badges/brazucaz-php-database/health.svg)

```
[![Health](https://phpackages.com/badges/brazucaz-php-database/health.svg)](https://phpackages.com/packages/brazucaz-php-database)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
