PHPackages                             turbopixel/phpdo-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. [Database &amp; ORM](/categories/database)
4. /
5. turbopixel/phpdo-database

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

turbopixel/phpdo-database
=========================

A lightweight PHP7 database wrapper class.

1.5.0(3y ago)12721MITPHPPHP &gt;=7.2

Since Apr 16Pushed 3y agoCompare

[ Source](https://github.com/turbopixel/PHPDO-Database)[ Packagist](https://packagist.org/packages/turbopixel/phpdo-database)[ Docs](https://github.com/turbopixel/PHPDO-Database)[ RSS](/packages/turbopixel-phpdo-database/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)DependenciesVersions (10)Used By (0)

PHPDO
=====

[](#phpdo)

[![GitHub code size in bytes](https://camo.githubusercontent.com/59cea6c63a415acb4f39be9a50142f00be585af8ee7f0f92d624768852c9d3e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f747572626f706978656c2f504850444f2d4461746162617365)](https://camo.githubusercontent.com/59cea6c63a415acb4f39be9a50142f00be585af8ee7f0f92d624768852c9d3e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f747572626f706978656c2f504850444f2d4461746162617365)[![MIT license](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://github.com/turbopixel/PHPDO-Database/blob/master/LICENSE)[![GitHub contributors](https://camo.githubusercontent.com/02dbad6c0a82f13ea05770fabe6f9b31ee772fbdad6e37fdb714f4a4c83fd7a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f747572626f706978656c2f504850444f2d4461746162617365)](https://camo.githubusercontent.com/02dbad6c0a82f13ea05770fabe6f9b31ee772fbdad6e37fdb714f4a4c83fd7a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f747572626f706978656c2f504850444f2d4461746162617365)[![GitHub last commit](https://camo.githubusercontent.com/b2d915660abed11d5d556b465a6c314564304e388ab1d8c007d3af1d9e6c0f9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f747572626f706978656c2f504850444f2d4461746162617365)](https://camo.githubusercontent.com/b2d915660abed11d5d556b465a6c314564304e388ab1d8c007d3af1d9e6c0f9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f747572626f706978656c2f504850444f2d4461746162617365)[![packagist](https://camo.githubusercontent.com/660381c6890654c4980a6f9200a42b00b0efeb5d169b80b6d8d5833581088d7f/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f747572626f706978656c2f504850444f2d4461746162617365)](https://packagist.org/packages/turbopixel/phpdo-database)

A lightweight PHP PDO database singleton wrapper class.

Docs and examples: [github.com/turbopixel/PHPDO-Database](https://github.com/turbopixel/PHPDO-Database)

### Requirements

[](#requirements)

- PHP 7.2+
- MySQL/MariaDB

### Install via composer

[](#install-via-composer)

```
composer require turbopixel/phpdo-database

```

Example
-------

[](#example)

```
PHPDO::connect("database-server.com", "database_name", "user_name", "myPassword123");

PHPDO::get()->query("SELECT stars FROM github")->fetchAll();
```

class PHPDO
-----------

[](#class-phpdo)

### Create database connection

[](#create-database-connection)

```
\PHPDO\PHPDO::connect("database-server.com", "database_name", "user_name", "myPassword123");
```

An existing PDO object can be set instead

```
// $pdoObject = new PDO();

PHPDO::setPdo($pdoObject);
```

After this, you can use the PHPDO class from everywhere.

Get instance
------------

[](#get-instance)

**\\PHPDO\\PHPDO::get()** returns the PHPDO instance

```
\PHPDO\PHPDO::get()
```

Example: Select rows

```
\PHPDO\PHPDO::get()->query("SELECT * FROM github")->fetchAll();
```

**Get PDO instance**

```
\PHPDO\PHPDO::get()->getPdo()
```

Run MySQL query
---------------

[](#run-mysql-query)

**query**

```
\PHPDO\PHPDO::get()->query("SELECT id FROM user WHERE active = 1");
print_r( $pdoStmnt->fetch() );
```

**execute**

```
\PHPDO\PHPDO::get()->execute("UPDATE user SET active = 0 WHERE mail IS NULL");
```

**Prepared Statement**

```
\PHPDO\PHPDO::get()->prepare("UPDATE github SET stars = stars+1 WHERE id = :id", ["id" => 1234]);
```

Helper
------

[](#helper)

### fetch() - Select a single row

[](#fetch---select-a-single-row)

```
\PHPDO\PHPDO::get()->fetch("SELECT id FROM github WHERE id = :repo", ["repo" => 553]);
```

`\PHPDO\PHPDO::get()->fetch()` is a helper method and replace this:

```
$rows  = [];
$stmnt = \PHPDO\PHPDO::get()->prepare("SELECT * FROM github WHERE id = ?", [
  1234
]);

if($stmnt instanceof PDOStatement){
  $rows = $stmnt->fetchAll();
}else{
 die("QUERY ERROR");
}

print_r($rows);
```

### fetchAll() - Select multiple rows

[](#fetchall---select-multiple-rows)

```
\PHPDO\PHPDO::get()->fetchAll("SELECT id FROM github WHERE id = :repo", ["repo" => 553]);
```

### rowCount() - Count rows

[](#rowcount---count-rows)

```
\PHPDO\PHPDO::get()->rowCount("SELECT id FROM github WHERE id = :repo", ["repo" => 553]);
```

### isTable() - Check table exists (MySQL only)

[](#istable---check-table-exists-mysql-only)

```
\PHPDO\PHPDO::get()->isTable("user_settings")
```

### findPrimaryIndexColumn() - Find table index column (MySQL only)

[](#findprimaryindexcolumn---find-table-index-column-mysql-only)

```
\PHPDO\PHPDO::get()->findPrimaryIndexColumn("tablename", "databasename")
```

Internal class logging
----------------------

[](#internal-class-logging)

All SQL Queries stored in PHPDO::$logs (array). Attribute `\PHPDO\PHPDO::$logging` must be `true`

**Enable logging**

```
\PHPDO\PHPDO::$logging = true;
```

**Get internal query logs**
Get query logs.

```
\PHPDO\PHPDO::get()->getLog(); // returns an array
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~221 days

Recently: every ~320 days

Total

9

Last Release

1183d ago

PHP version history (2 changes)1.0.5PHP &gt;=7.0

1.1.4PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bb81d5bdef7e45104762400e196bbc8543f828f446b6f5cb4c880940231a213?d=identicon)[turbopixel](/maintainers/turbopixel)

---

Top Contributors

[![turbopixel](https://avatars.githubusercontent.com/u/15839724?v=4)](https://github.com/turbopixel "turbopixel (68 commits)")

---

Tags

databasemysqlpdo-mysqlphpphp7phpdatabasemysqlpdowrapperlightweightPHP7

### Embed Badge

![Health badge](/badges/turbopixel-phpdo-database/health.svg)

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

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[stefangabos/zebra_database

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

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

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[riverside/php-orm

PHP ORM micro-library and query builder

111.2k](/packages/riverside-php-orm)

PHPackages © 2026

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