PHPackages                             bentools/mysqliextended - 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. bentools/mysqliextended

Abandoned → [bentools/simple-dbal](/?search=bentools%2Fsimple-dbal)Library[Database &amp; ORM](/categories/database)

bentools/mysqliextended
=======================

An enhanced MySqli class

1.1(10y ago)0831[1 PRs](https://github.com/bpolaszek/bentools-mysqliextended/pulls)MITPHPPHP &gt;=5.3

Since Jul 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bpolaszek/bentools-mysqliextended)[ Packagist](https://packagist.org/packages/bentools/mysqliextended)[ Docs](https://github.com/bpolaszek/bentools-mysqliextended)[ RSS](/packages/bentools-mysqliextended/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (7)Used By (0)

**This package is abandonned. Consider upgrading to [bentools/simple-dbal](https://github.com/bpolaszek/simple-dbal), which can handle PDO and Mysqli connections as well, and favors composition over inheritance.**

MySqli Extended
===============

[](#mysqli-extended)

A better experience of PHP MySqli.

Shortcuts
---------

[](#shortcuts)

**BenTools\\MySqliExtended\\MySqliExtended** is a child class of *\\MySqli*. It has several shortcut methods to fetch data :

- *sqlArray()* -&gt; fetch a multi-dimensionnal array, basically several rows in a table.
- *sqlRow()* -&gt; fetch an associative array, for example a row.
- *sqlColumn()* -&gt; fetch the 1st column as an indexed array.
- *sqlValue()* -&gt; fetch a specific value.

```
$cnx = new MySqliExtended();
$cnx->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);

$cnx->real_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

$query = "SELECT 'Bill' AS firstname, 'Gates' AS lastname UNION SELECT 'Tim' AS firstname, 'Cook' AS lastname";
$result = $cnx->sqlArray($query);

Output:
array (
  0 =>
  array (
    'firstname' => 'Bill',
    'lastname' => 'Gates',
  ),
  1 =>
  array (
    'firstname' => 'Tim',
    'lastname' => 'Cook',
  ),
)

$result = $cnx->sqlRow($query);
Output:
array (
  'firstname' => 'Bill',
  'lastname' => 'Gates',
)

$result = $cnx->sqlColumn($query);
Output:
array (
  0 => 'Bill',
  1 => 'Tim',
)

$result = $cnx->sqlValue($query);
Output:
'Bill'
```

Prepared Statements
-------------------

[](#prepared-statements)

Working with prepared statements is now easier than before :

```
// Before :
$query = "INSERT INTO `ceo` (firstname, lastname, years_in_company) VALUES (?, ?, ?)";
$stmt = $cnx->prepare($query);
$firstname = 'Larry';
$lastname = 'Page';
$years_in_company = 12;
$stmt->bind_param('ssi', $firstname, $lastname, $years_in_company);
$stmt->execute();

// Now :
$stmt = $cnx->prepare($query);
$stmt->sql(array(
    'Larry',
    'Page',
    12
));

// or directly :
$cnx->sql($query, array(
    'Larry',
    'Page',
    12
));

// or very shortly :
$cnx($query, array(
    'Larry',
    'Page',
    12
));
```

You no longer need to create variables, create references and create a weird type-hinting string, i.e. 'ssi'.

You can also use **named parameters** (like with **PDO**), that you can duplicate in the same query :

```
$query = "INSERT INTO `ceo` (firstname, lastname, years_in_company) VALUES (:firstname, :lastname, :years_in_company) ON DUPLICATE KEY UPDATE years_in_company = :years_in_company";
$cnx->sql($query, array(
    'firstname' => 'Larry',
    'lastname' => 'Page',
    'years_in_company' => 12
));
```

Easily work with **prepared statements**.

```
$query = "SELECT firstname, lastname FROM `ceo` WHERE firstname LIKE ?";
$result = $cnx($query)->sqlRow('bill%');

Ouput :
array (
  'firstname' => 'Bill',
  'lastname' => 'Gates',
)

$result = $cnx($query)->sqlRow('larry%');

Ouput :
array (
  'firstname' => 'Larry',
  'lastname' => 'Page',
)

$query = "SELECT firstname, lastname FROM `ceo` WHERE (firstname LIKE :firstname OR years_in_company > :years)";
$result = $cnx($query)->sqlArray(array(
    'firstname' => 'larry%',
    'years'      => 10
));

Output:
array (
  0 =>
  array (
    'firstname' => 'Bill',
    'lastname' => 'Gates',
  ),
  1 =>
  array (
    'firstname' => 'Tim',
    'lastname' => 'Cook',
  ),
  2 =>
  array (
    'firstname' => 'Larry',
    'lastname' => 'Page',
  ),
)
```

Installation
------------

[](#installation)

Add the following line into your composer.json :

```
{
    "require": {
        "bentools/mysqliextended": "1.0.x"
    }
}

```

Enjoy.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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.

###  Release Activity

Cadence

Every ~45 days

Recently: every ~51 days

Total

6

Last Release

3730d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/acdd1a8ee0e657ddd06cf11f98a32100ef7121afb8aa270a5b295f5c29c038b3?d=identicon)[bpolaszek](/maintainers/bpolaszek)

---

Top Contributors

[![ben-synapse](https://avatars.githubusercontent.com/u/36077477?v=4)](https://github.com/ben-synapse "ben-synapse (5 commits)")[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (3 commits)")

---

Tags

databasemysqlConnectionmysqliextendedmysqliextendedmysqli extended

### Embed Badge

![Health badge](/badges/bentools-mysqliextended/health.svg)

```
[![Health](https://phpackages.com/badges/bentools-mysqliextended/health.svg)](https://phpackages.com/packages/bentools-mysqliextended)
```

###  Alternatives

[sergeytsalkov/meekrodb

The Simple PHP/MySQL Library

341387.0k10](/packages/sergeytsalkov-meekrodb)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[go/db

Database library

6624.1k](/packages/go-db)[krugozor/database

PHP class library for simple, convenient, fast and safe work with MySql database, using PHP mysqli extension and imitation of prepared queries.

392.5k](/packages/krugozor-database)

PHPackages © 2026

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