PHPackages                             itools/zendb - 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. itools/zendb

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

itools/zendb
============

Injection-proof PHP/MySQL database layer with automatic XSS-safe output

v0.9.1(2mo ago)3218↓90%1MITPHPPHP ^8.1CI passing

Since Apr 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/interactivetools-com/ZenDB)[ Packagist](https://packagist.org/packages/itools/zendb)[ Docs](https://github.com/interactivetools-com/ZenDB)[ RSS](/packages/itools-zendb/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

ZenDB: PHP/MySQL Database Library
=================================

[](#zendb-phpmysql-database-library)

A PHP/MySQL database layer that's easy to use and hard to misuse.

- **SQL injection is impossible:** ZenDB rejects any query with inline values. Every dynamic value goes through placeholders, not because you remembered, but because there's no other way.
- **XSS is prevented by default:** Every value from the database HTML-encodes itself on output. You don't call `htmlspecialchars()`. Neither does the next developer.
- **Fast to learn, fast to use:** The methods mirror SQL: `select`, `insert`, `update`, `delete`. If you know MySQL, you already know ZenDB, and if you don't, you will soon!

Why SQL?
--------

[](#why-sql)

Most database libraries invent their own query language - chained methods, builder patterns - that ends up just as complex as SQL but less powerful. ZenDB takes the opposite approach: **don't teach people a complicated thing that replaces SQL. Just use SQL and make it safe.**

`SELECT`, `WHERE`, `JOIN`, `ORDER BY` - that's all you need to query with ZenDB. The library handles the security (parameterization, escaping, validation) so you can write the SQL you already know without worrying about injection.

What's Inside
-------------

[](#whats-inside)

- [30-Second Quickstart](#30-second-quickstart)
- [Getting Started](docs/01-getting-started.md) - Installation, connection, first queries
- [Method Reference](docs/11-method-reference.md) - Every method, parameter type, and return value
- [AI Quick Reference](docs/00-ai-reference.md) - Single-page reference for AI assistants and humans alike

More documentation coming soon - querying, results, joins, placeholders, and more.

30-Second Quickstart
--------------------

[](#30-second-quickstart)

```
composer require itools/zendb
```

```
use Itools\ZenDB\DB;

// Connect
DB::connect([
    'hostname'    => 'localhost',
    'username'    => 'dbuser',
    'password'    => 'secret',
    'database'    => 'my_app',
    'tablePrefix' => 'app_',   // optional
]);

// Select rows
$users = DB::select('users', "status = ?", 'active');
foreach ($users as $user) {
    echo "Hello, $user->name!"; // auto HTML-encoded
}

// Get a single row
$user = DB::selectOne('users', "id = ?", 1);

// Insert a row
$newId = DB::insert('users', [
    'name'  => 'Alice',
    'city'  => 'Vancouver',
]);

// Update a row
$newValues = ['city' => 'Toronto'];
$where     = ['id' => $newId]; // arrays work too
DB::update('users', $newValues, $where);

// Delete a row
DB::delete('users', ['id' => $newId]);

// Full SQL when you need it (:: inserts your table prefix)
$rows = DB::query("SELECT name, city FROM ::users WHERE status = :status AND city = :city", [
    ':status' => 'active',
    ':city'   => 'Vancouver',
]);
```

When you might NOT want ZenDB
-----------------------------

[](#when-you-might-not-want-zendb)

- You need an ORM with models, migrations, or an ActiveRecord pattern
- You need to support databases other than MySQL/MariaDB (and compatible alternatives)
- You need async or non-blocking database queries
- You prefer writing raw SQL without any abstraction

Related Libraries
-----------------

[](#related-libraries)

- [SmartArray](https://github.com/interactivetools-com/SmartArray) - Enhanced arrays with chainable methods
- [SmartString](https://github.com/interactivetools-com/SmartString) - Secure string handling with auto HTML-encoding

Questions?
----------

[](#questions)

Post a message in our [forum](https://www.interactivetools.com/forum/).

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance86

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.4% 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 ~21 days

Total

2

Last Release

70d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/498283?v=4)[itools](/maintainers/itools)[@iTools](https://github.com/iTools)

---

Top Contributors

[![daveedis](https://avatars.githubusercontent.com/u/22456364?v=4)](https://github.com/daveedis "daveedis (37 commits)")[![Martyr2](https://avatars.githubusercontent.com/u/320707?v=4)](https://github.com/Martyr2 "Martyr2 (1 commits)")

---

Tags

databasemysqldbalsqlsecurecrudmysqlidatabase layerparameterized-queriesinjection-proof

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/itools-zendb/health.svg)

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.7k](/packages/doctrine-dbal)[ezsql/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86748.3k](/packages/ezsql-ezsql)[jv2222/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

87211.6k2](/packages/jv2222-ezsql)[cycle/database

DBAL, schema introspection, migration and pagination

71777.8k52](/packages/cycle-database)

PHPackages © 2026

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