PHPackages                             whitwhoa/simple-mysql - 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. whitwhoa/simple-mysql

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

whitwhoa/simple-mysql
=====================

A more simple way to interact with MySQL via php

121PHP

Since Oct 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/whitwhoa/simple-mysql)[ Packagist](https://packagist.org/packages/whitwhoa/simple-mysql)[ RSS](/packages/whitwhoa-simple-mysql/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

SimpleMySQL
===========

[](#simplemysql)

- Tired of scouring php.net for the function names to utilize PDO every time you need to interact with MySQL?
- Frustrated with the amount of redundant code you have to write to build a result set that's easily usable by your application? (I mean all you want to do is `SELECT * FROM table WHERE col = ?` and display the results as html table rows...why are you now thinking about data types of parameters which you'll have to bind to a prepared statement...why are you wasting time?)
- Stuck working outside modern php frameworks that include fancy ORMS?
- Want simplicity in database interaction without the bloat of a full fledged ORM?
- Are you a sane rational human being (or other form of entity which possesses a rational thought pattern)?

### If you have answered `YES` to any of the above, `SimpleMySQL` might be right for you. Please consult with your senior developer today!

[](#if-you-have-answered-yes-to-any-of-the-above-simplemysql-might-be-right-for-you-please-consult-with-your-senior-developer-today)

Install via composer
--------------------

[](#install-via-composer)

`composer require whitwhoa/simple-mysql`

Usage
-----

[](#usage)

```
use whitwhoa\SimpleMySQL\MySQLCon;

/**
 * First parameter is an array of the following:
 *
 * [
 *      host, username, password, database
 * ]
 *
 * It is advised to store this information in a directory outside
 * of your webroot if using this package within a web application.
 * (for example create a file called connections.php containing multiple
 * array variables with connection details for various connections, include
 * the file at the top of your script and pass the variable containing the
 * connection information you wish to instantiate a MySQLCon object for.)
 *
 * If boolean true is passed as second parameter, error reporting will be turned on
 * (don't do this in production). Class could be updated to print more detailed errors.
 *
 */
$db = new MySQLCon(['localhost', 'root', 'root', 'testDB'], true);

// Obtain results as an array of stdClass objects
$users = $db->query('SELECT * FROM users')->asObj()->exec();
foreach($users as $u){
    echo $u->email . "\n";
}

// Obtain a single row as an stdClass object
$user = $db->query("SELECT * FROM users WHERE id = ?", [7])->singleAsObj()->exec();
echo $user->email;

// Obtain results as an array of associative arrays
$users = $db->query('SELECT * FROM users')->asArray()->exec();
foreach($users as $u){
    echo $u['email'] . "\n";
}

// Obtain a single row as an associative array
$user = $db->query("SELECT * FROM users WHERE id = ?", [7])->singleAsArray()->exec();
echo $user['email'];

// Insert a new record and obtain it's primary key value
$id = $db->query("INSERT INTO test(name) VALUES(?)", ['Richard'])->exec();
echo $id;

// Update an existing record (returns void)
$db->query("UPDATE test SET name = ? WHERE id = ?", ['Tom', 3])->exec();

// Delete an existing record (returns void)
$db->query("DELETE FROM test WHERE id = ?", [3])->exec();
```

Caution
-------

[](#caution)

### If you experience any of the following symptoms please stop using SimpleMySQL and contact your senior developer immediately:

[](#if-you-experience-any-of-the-following-symptoms-please-stop-using-simplemysql-and-contact-your-senior-developer-immediately)

- Data loss and or corruption
- Poor performance
- Random intermittent issues which no one can explain
- Project managers now putting more pressure on you to get projects done faster since you've found a tool that allows you to be more efficient at your job
- A burning sensation when you urinate

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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/ffc43d2184030938bd22b7b4895f6761bb4c9a146b870d31076aed1025653be7?d=identicon)[whitwhoa](/maintainers/whitwhoa)

---

Top Contributors

[![whitwhoa](https://avatars.githubusercontent.com/u/8580531?v=4)](https://github.com/whitwhoa "whitwhoa (14 commits)")

### Embed Badge

![Health badge](/badges/whitwhoa-simple-mysql/health.svg)

```
[![Health](https://phpackages.com/badges/whitwhoa-simple-mysql/health.svg)](https://phpackages.com/packages/whitwhoa-simple-mysql)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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