PHPackages                             legale/mysqli - 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. legale/mysqli

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

legale/mysqli
=============

A real safe and convenient way to handle MySQL queries.

1.0.0(3y ago)06bsd-2-clausePHPPHP &gt;=5.0.0

Since Jul 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/legale/php-mysqli)[ Packagist](https://packagist.org/packages/legale/mysqli)[ Docs](https://github.com/legale/php-mysqli)[ RSS](/packages/legale-mysqli/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-mysqli
==========

[](#php-mysqli)

Simple php mysqli driver based mysql library. Based on colshrapnel/safemysql library.

installation
------------

[](#installation)

`composer require legale/mysqli`

usage example
-------------

[](#usage-example)

```
 /*
  * Supported placeholders at the moment are:
  *  ?s ("string")  - strings (also DATE, FLOAT and DECIMAL)
  *  ?i ("integer") - the name says it all
  * ?n ("name")    - identifiers (table and field names)
  * ?a ("array")   - complex placeholder for IN() operator  (substituted with string of 'a','b','c' format, without parentesis)
  * ?u ("update")  - complex placeholder for SET operator (substituted with string of `field`='value',`field`='value' format)
  * ?p ("parsed") - special type placeholder, for inserting already parsed statements without any processing, to avoid double parsing.
  */

 //Connection:

 $db = new Db(); // with default settings

 $opts = array(
		'user'    => 'user',
		'pass'    => 'pass',
		'db'      => 'db',
		'charset' => 'latin1'
 );
 $db = new Db($opts); // with some of the default settings overwritten

/* Alternatively, you can just pass an existing mysqli instance that will be used to run queries
 instead of creating a new connection.
 Excellent choice for migration!*/

 $db = new Db(['mysqli' => $mysqli]);

 //Some examples:

 $name = $db->getOne('SELECT name FROM table WHERE id = ?i',$_GET['id']);
 $data = $db->getInd('id','SELECT * FROM ?n WHERE id IN ?a','table', array(1,2));
 $data = $db->getAll("SELECT * FROM ?n WHERE mod=?s LIMIT ?i",$table,$mod,$limit);

 $ids  = $db->getCol("SELECT id FROM tags WHERE tagname = ?s",$tag);
 $data = $db->getAll("SELECT * FROM table WHERE category IN (?a)",$ids);

 $data = array('offers_in' => $in, 'offers_out' => $out);
 $sql  = "INSERT INTO stats SET pid=?i,dt=CURDATE(),?u ON DUPLICATE KEY UPDATE ?u";
 $db->query($sql,$pid,$data,$data);

 if ($var === NULL) {
     $sqlpart = "field is NULL";
 } else {
     $sqlpart = $db->parse("field = ?s", $var);
 }
 $data = $db->getAll("SELECT * FROM table WHERE ?p", $bar, $sqlpart);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1389d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/543f3f2812313795ae0d37db83422315a90a80c62036ee86a3f197ec9f36fd70?d=identicon)[legale](/maintainers/legale)

---

Top Contributors

[![legale](https://avatars.githubusercontent.com/u/32621719?v=4)](https://github.com/legale "legale (1 commits)")

---

Tags

mysqldb

### Embed Badge

![Health badge](/badges/legale-mysqli/health.svg)

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

###  Alternatives

[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925511.7k13](/packages/envms-fluentpdo)[lichtner/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921274.8k6](/packages/lichtner-fluentpdo)[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921244.9k7](/packages/fpdo-fluentpdo)[danielme85/laravel-log-to-db

Custom Laravel Log channel handler that can store log events to SQL or MongoDB databases. Uses Laravel native logging functionality.

135934.5k1](/packages/danielme85-laravel-log-to-db)[colshrapnel/safemysql

A real safe and convenient way to handle MySQL queries.

400103.5k4](/packages/colshrapnel-safemysql)

PHPackages © 2026

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