PHPackages                             falseclock/dbd-php - 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. falseclock/dbd-php

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

falseclock/dbd-php
==================

Database driver for PHP (PostgreSQL, MySQL, MSSQL, OData, YellowERP, 1С)

3.1.4(5mo ago)116.8k↓40%6MITPHPPHP &gt;=8.0CI failing

Since Mar 21Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/Falseclock/dbd-php)[ Packagist](https://packagist.org/packages/falseclock/dbd-php)[ RSS](/packages/falseclock-dbd-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (32)Used By (0)

PostgreSQL Database driver for PHP
----------------------------------

[](#postgresql-database-driver-for-php)

[![PHP](https://github.com/Falseclock/dbd-php/actions/workflows/php.yml/badge.svg)](https://github.com/Falseclock/dbd-php/actions/workflows/php.yml)[![Coverage Status](https://camo.githubusercontent.com/6576573d92403257ea9062c18675358923abaeb203c5197036cd38e1a5f57159/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f46616c7365636c6f636b2f6462642d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Falseclock/dbd-php?branch=master)[![PHP Version Require](https://camo.githubusercontent.com/efc1db03891a1d2c27444e465d18c3075446179ed30771cc917b2fc13605ccca/687474703a2f2f706f7365722e707567782e6f72672f66616c7365636c6f636b2f6462642d7068702f726571756972652f706870)](https://packagist.org/packages/falseclock/dbd-php)

[![Latest Stable Version](https://camo.githubusercontent.com/a3a302f30d2988bcd4dbd68b5476ec8bbcecc6ea35d091c0997958569ff64290/68747470733a2f2f706f7365722e707567782e6f72672f66616c7365636c6f636b2f6462642d7068702f76)](//packagist.org/packages/falseclock/dbd-php)[![Total Downloads](https://camo.githubusercontent.com/f50f446e752b2ebd475f6dbf73d659de4a321ce109b98e28f6857ddd86334a52/68747470733a2f2f706f7365722e707567782e6f72672f66616c7365636c6f636b2f6462642d7068702f646f776e6c6f616473)](//packagist.org/packages/falseclock/dbd-php)[![Latest Unstable Version](https://camo.githubusercontent.com/8af04beb3c855db5ae2123bf568fb8ab37b54a6427ee7059076bda4af0e109c8/68747470733a2f2f706f7365722e707567782e6f72672f66616c7365636c6f636b2f6462642d7068702f762f756e737461626c65)](//packagist.org/packages/falseclock/dbd-php)[![License](https://camo.githubusercontent.com/ab5b3d19f1baa2bdb507c6459e8005215adb6f6474536626053cce26933426fa/68747470733a2f2f706f7365722e707567782e6f72672f66616c7365636c6f636b2f6462642d7068702f6c6963656e7365)](//packagist.org/packages/falseclock/dbd-php)

#### Why not standard PDO?

[](#why-not-standard-pdo)

Actually, development of this library was started before PHP 5.0. Being mostly Perl developer and inspired by DBI::DBD library I tried to develop the same functionality for PHP.

#### Basic feature list:

[](#basic-feature-list)

- Much comfortable and easier than PDO
- SQL injections protection
- DBD/DBI perl-like library
- Easy caching integration
- Better error handling
- Measurements and debugging
- Extendable by other drivers (only PostgreSQL fully ready)
- Automatic conversion of records to object with dbd-php-entity library

Getting instance
----------------

[](#getting-instance)

Very and very easy:

```

```

Basic methods
-------------

[](#basic-methods)

- [connect](#connect)
- [do](#do)
- [query](#query)
- [prepare](#prepare)
- [execute](#execute)
- [fetch](#fetch)
- [fetchRow](#fetchrow)
- [fetchRowSet](#fetchrowset)
- [fetchArraySet](#fetcharrayset)
- [insert](#insert)
- [update](#update)
- [begin](#begin)
- [commit](#commit)
- [rollback](#rollback)
- [cache](#cache)
- [isAffected](#isaffected)
- [escape](#escape)
- [affectedRows](#affectedrows)
- [entityInsert](#entityinsert)
- [entitySelect](#entityselect)
- [entityUpdate](#entityupdate)
- [entityDelete](#entitydelete)
- [disconnect](#disconnect)

---

**connect**
===========

[](#connect)

**connect** — initiate connection to a database

### Description

[](#description)

```
resource connect ()
```

**connect()** opens a connection to a database using **Option** instance provided in construction.

---

**do**
======

[](#do)

**do** — Returns number of affected records (tuples)

### Description

[](#description-1)

```
int do ( string $statement [, mixed $params ] )
```

**do()** returns the number of tuples (instances/records/rows) affected by INSERT, UPDATE, and DELETE queries.

Since PostgreSQL 9.0 and above, the server returns the number of SELECTed rows. Older PostgreSQL return 0 for SELECT.

### Parameters

[](#parameters)

***statement***

> The SQL statement to be executed. Can have placeholders. Must contain only a single statement (multiple statements separated by semi-colons are not allowed). If any parameters are used, they are referred to as ?, ?, etc.

***params***

> An array of parameter values to substitute for the ?, ?, etc. placeholders in the original prepared SQL statement string. The number of elements in the array must match the number of placeholders.

### Example

[](#example)

```

```

---

**query**
=========

[](#query)

**query** — quick statement execution

### Description

[](#description-2)

```
resource query ( string $statement [, mixed $params ] )
```

**query()** do the same as [do](#do)() method, but returns self instance.

### Parameters

[](#parameters-1)

***statement***

> The SQL statement to be executed. Can have placeholders. Must contain only a single statement (multiple statements separated by semi-colons are not allowed). If any parameters are used, they are referred to as ?, ?, etc.

***params***

> An array of parameter values to substitute for the ?, ?, etc. placeholders in the original prepared SQL statement string. The number of elements in the array must match the number of placeholders.

### Example

[](#example-1)

```
