PHPackages                             catsand/pdo-database-wrapper - 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. catsand/pdo-database-wrapper

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

catsand/pdo-database-wrapper
============================

PDO wrapper with easy syntax for fast development :+1:

v1.0(9y ago)032MITPHPPHP &gt;=5.3.0

Since Sep 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/catsAND/PDO-Database-Wrapper)[ Packagist](https://packagist.org/packages/catsand/pdo-database-wrapper)[ Docs](https://github.com/catsAND/PDO-Database-Wrapper)[ RSS](/packages/catsand-pdo-database-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

PDO Database Wrapper
====================

[](#pdo-database-wrapper)

Simple PDO Wrapper with named and question mark placeholders for easy and fast development. Try it!

Requirements
------------

[](#requirements)

- PHP 5.3 or greater
- PDO extension

Instalation
-----------

[](#instalation)

### Download the files.

[](#download-the-files)

- You can [download](https://github.com/catsAND/PDO-Database-Wrapper/archive/v1.0.zip) them directly and extract them to your web directory.

### [Composer](https://getcomposer.org)

[](#composer)

- `composer require catsand/pdo-database-wrapper`

### Clone the repo

[](#clone-the-repo)

- `git clone https://github.com/catsAND/PDO-Database-Wrapper.git`

Features
--------

[](#features)

- Simple syntax.
- Question mark placeholders with types.
- Named placeholders.

Functions
---------

[](#functions)

### List

[](#list)

```
public query($sql, ...value)

public select($sql, ...value)

public selectCell($sql, ...value);
public column($sql, ...value);
public cell($sql, ...value);

public selectRow($sql, ...value);
public fetch($sql, ...value);
public row($sql, ...value);

public selectArray($sql, ...value);

public selectHash($sql, ...value);
public hash($sql, ...value);

public insert($tableName, $valueArray, $columnsArray = array);
public insertIgnore($tableName, $valueArray, $columnsArray = array);
public replace($tableName, $valueArray, $columnsArray = array);

public getLastId();
public lastId();

public getRowCount();

public beginTransaction();
public start();

public executeTransaction();
public finish();
public commit();

public rollBack();
public cancel();

public lock($tableNames);

public unlock();
```

- query

```
public query($sql, ...value)
```

Return number of affected rows

- select

```
public select($sql, ...value)
```

Return array with results

- selectCell

```
public selectCell($sql, ...value);
```

Return string with first column value from first row

- selectRow

```
public selectRow($sql, ...value);
```

Return array with all columns from first row

- selectArray

```
public selectArray($sql, ...value);
```

Return array with first columns from rows as value

- selectHash

```
public selectHash($sql, ...value);
```

Return array with first columns from rows as key and second columns from rows as value

- insert, insertIgnore, replace

```
public insert($tableName, $valueArray, $columnsArray = array);
public insertIgnore($tableName, $valueArray, $columnsArray = array);
public replace($tableName, $valueArray, $columnsArray = array);
```

Return numbers of affected rows

**Column names obligatory need to be in $valueArray first array as key or in $columnsArray array as value.**

### Examples

[](#examples)

```
  $db = new Database\Database('localhost', 'dbname', 'user', 'password');
  $result = $db->select('SELECT COLUMN1, COLUMN2, COLUMN3 FROM `table_name` WHERE COLUMN4 = ?s AND COLUMN5 = ?i OR COLUMN6 = ?', 'column4', 5, 'column6');
```

```
 $db->insert('table_name', array(array('COLUMN1' => 123, 'COLUMN2' => 123), array(234, 234), array(345, 345), array(456, 456)));
 $db->insert('table_name', array(123, 123));
 $db->insertIgnore('table_name', array(array(123, 123), array(234, 234), array(345, 345), array(456, 456)), array('COLUMN1', 'COLUMN2'));
 $db->replace('table_name', array(123, 123), array('COLUMN1', 'COLUMN2'));
```

### Avalaible placeholders:

[](#avalaible-placeholders)

**? — bind value with autotype**

```
select('SELECT * FROM `table_name` WHERE `COLUMN1` = ? OR `COLUMN2` = ?', 'VALUE', 5);
```

```
SELECT * FROM `table_name` WHERE `COLUMN1` = 'VALUE' OR `COLUMN2` = 5;
```

**?r — bind raw value to SQL query without verification**

```
select('SELECT * FROM ?r WHERE `?r` > 1', '`table_name`', 'COLUMN');
```

```
SELECT * FROM `table_name` WHERE `COLUMN` > 1;
```

**?i — bind value as integer**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` = ?i', 23);
```

```
SELECT * FROM `table_name` WHERE `COLUMN` = 23;
```

**?s — bind value as string**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` = ?s', 'string');
```

```
SELECT * FROM `table_name` WHERE `COLUMN` = 'string';
```

**?f — bind value as float**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` = ?f OR `COLUMN` = ?f', 3.1415926535, '2.71828');
```

```
SELECT * FROM `table_name` WHERE `COLUMN` = '3.1415926535' OR `COLUMN` = '2.71828';
```

**?b — bind value as boolean**

**?n — bind value as null**

**?q — bind value as string without HTML tags**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` = ?s', 'string');
```

```
SELECT * FROM `table_name` WHERE `COLUMN` = 'string';
```

**?a — bind value as integer array.**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` IN (?a)', array(10, '20', '30', 40.3));
```

```
SELECT * FROM `table_name` WHERE `COLUMN` IN (10, 20, 30, 40);
```

**?j — bind value as string array.**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` IN (?j)', array('p', 'd', 'o'));
```

```
SELECT * FROM `table_name` WHERE `COLUMN` IN ('p', 'd', 'o');
```

**?h — bind value as string array with key as column name and value as column value.**

```
select('UPDATE `table_name` SET ?h', array('COLUMN1' => 'One', 'COLUMN2' => 'Two', 'COLUMN3' => 'Three'));
```

```
UPDATE `table_name` SET `COLUMN1` = 'One', `COLUMN2` = 'Two', `COLUMN3` = 'Three';
```

**?w — bind value as string array with key as column name and value as column value with delimiter AND.**

```
select('SELECT * FROM `table_name` WHERE ?w', array('COLUMN1' => 'Three', 'COLUMN2' => 'Two', 'COLUMN3' => 'One'));
```

```
SELECT * FROM `table_name` WHERE `COLUMN1` = 'Three' AND `COLUMN2` = 'Two' AND `COLUMN3` = 'One';
```

**Named placeholders**

```
select('SELECT * FROM `table_name` WHERE `COLUMN` = :val OR `COLUMN` :val2', array(':val' => 'VALUE', ':val2' => 'VALUE'));
```

```
SELECT * FROM `table_name` WHERE `COLUMN` = 'VALUE' OR `COLUMN2` = 'VALUE';
```

Support
-------

[](#support)

If you like this script please support by staring or forking the repository.

How to contribute
-----------------

[](#how-to-contribute)

Always welcome

- Create an [issue](https://github.com/catsAND/PDO-Database-Wrapper/issues) on GitHub, if you have found a bug or for enhancement.
- Create a [Pull requests](https://github.com/catsAND/PDO-Database-Wrapper/pulls) for open bug/feature issues.

Thanks to
---------

[](#thanks-to)

- [Indieteq](https://github.com/indieteq)
- [Tino Ehrich](https://github.com/fightbulc)

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/catsAND/PDO-Database-Wrapper/blob/master/LICENSE) file for details

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~0 days

Total

2

Last Release

3537d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a1b9a5167a35bbaa582bbcb0ad61b297cc4777d934e95247c30be9aa0e89c4e?d=identicon)[catsAND](/maintainers/catsAND)

---

Top Contributors

[![catsAND](https://avatars.githubusercontent.com/u/5276331?v=4)](https://github.com/catsAND "catsAND (19 commits)")

---

Tags

mysqlpdopdo-wrapperphpphp5simple-mysqldatabasemysqlpdowrapper

### Embed Badge

![Health badge](/badges/catsand-pdo-database-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/catsand-pdo-database-wrapper/health.svg)](https://phpackages.com/packages/catsand-pdo-database-wrapper)
```

###  Alternatives

[lincanbin/php-pdo-mysql-class

A PHP MySQL PDO class similar to the Python MySQLdb, which supports iterator and parameter binding when using 'WHERE IN' statement.

2386.4k](/packages/lincanbin-php-pdo-mysql-class)

PHPackages © 2026

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