PHPackages                             xp-framework/rdbms - 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. xp-framework/rdbms

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

xp-framework/rdbms
==================

RDBMS support for the XP Framework

v13.4.0(9mo ago)278.4k↓13.3%43BSD-3-ClausePHPPHP &gt;=7.0.0CI passing

Since Jan 10Pushed 9mo ago4 watchersCompare

[ Source](https://github.com/xp-framework/rdbms)[ Packagist](https://packagist.org/packages/xp-framework/rdbms)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-rdbms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (71)Used By (3)

RDBMS support for the XP Framework
==================================

[](#rdbms-support-for-the-xp-framework)

[![Build status on GitHub](https://github.com/xp-framework/rdbms/workflows/Tests/badge.svg)](https://github.com/xp-framework/rdbms/actions)[![Build status on AppVeyor](https://camo.githubusercontent.com/71a589f599ba80c347a7c29a13b7a48726075cdeddb11f76e8713c3061f8fe8c/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f777974326367646e6b7661686c6171613f7376673d74727565)](https://ci.appveyor.com/project/thekid/rdbms)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/ee9dfe981ca46b14b2e8e23e4b2da75d5ebecdb324ce133da59a21c9382f9c35/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f7264626d732f76657273696f6e2e737667)](https://packagist.org/packages/xp-framework/rdbms)

RDBMS access APIs, connection manager, reverse engineering, O/R mapping.

The DriverManager model
-----------------------

[](#the-drivermanager-model)

To retrieve a connection class from the driver manager, you need to use the rdbms.DriverManager class.

```
use rdbms\DriverManager;

$conn= DriverManager::getConnection('sybase://user:pass@server/NICOTINE');
```

The DriverManager class expects a unified connection string (we call it DSN).

Supported drivers
-----------------

[](#supported-drivers)

The DriverManager will select an appropriate driver from the DSN string via its name. This will load an implemenation class which is either based on a PHP extension or implements the protocol to communicate with the database system in userland code. For the latter case, you need not do anything to your PHP setup; if there's a hard dependency on a PHP extension, you need to install that before you can use the driver.

*Database system**DSN name**PHP Extensions**Userland driver*MySQL`mysql`ext/mysql or ext/mysqli✅PostgreSQL`pgsql`ext/pgsqlSQLite3`sqlite`ext/sqlite3Interbase/FireBird`ibase`ext/interbaseSybase`sybase`ext/sybase-ct✅MSSQL`mssql`ext/mssql or ext/sqlsrv✅Basics
------

[](#basics)

Once we have fetched a specific database connection class, we can now invoke a number of methods on it.

### Selecting

[](#selecting)

Selecting can be done with the "one-stop" method `select()` which will return all results into an array. Alternatively, the `query()` method allows iterative fetching.

```
$news= $conn->select('news_id, caption, author_id from news');
// $news= [
//   [
//     'news_id'   => 12,
//     'caption'   => 'Hello World',
//     'author_id' => 1549
//   ]
// ]

$q= $conn->query('select news_id, caption, author_id from news');
while ($record= $q->next()) {
  // $record= [
  //   'news_id'   => 12,
  //   'caption'   => 'Hello World',
  //   'author_id' => 1549
  // ]
}
```

### Inserting

[](#inserting)

To "bind" parameters to an SQL query, the query, select, update, delete and insert methods offer a printf style tokenizer and support varargs syntax. These take care of NULL, type handling and proper escaping for you.

```
$conn->insert('
  into news (
    caption, author_id, body, extended, created_at
  ) values (
    %s, -- caption
    %d, -- author_id
    %s, -- body
    %s, -- extended
    %s  -- created_at
  )',
  $caption,
  $authorId,
  $body,
  $extended,
  Date::now()
);
```

### Updating

[](#updating)

The `update()` and `delete()` methods will return the number of affected rows, in case you're interested.

```
$conn->update('news set author_id= %d where author_id is null', $authorId);
```

### Deleting

[](#deleting)

Even if your RDBMS requires you to use single quotes (or what-else), the API will take care of rewriting string literals for you.

```
$conn->delete('from news where caption = "[DELETE]"');
```

Exceptions
----------

[](#exceptions)

All of the above methods will throw exceptions for failed SQL queries, syntax errors, connection failure etc. All these exceptions are subclasses of `rdbms.SQLException`, so to catch all possible errors, use it in the catch clause:

```
+ rdbms.SQLException
|-- rdbms.ConnectionNotRegisteredException
|-- rdbms.SQLConnectException
|-- rdbms.SQLStateException
`-- rdbms.SQLStatementFailedException
    |-- rdbms.SQLConnectionClosedException
    `-- rdbms.SQLDeadlockException

```

Transactions
------------

[](#transactions)

To start a transaction, you can use the connection's `begin()`, `commit()` and `rollback()` methods as follows:

```
public function createAuthor(...) {
  $tran= $conn->begin(new Transaction('create_author'));

  try {
    $id= $conn->insert('into author ...');
    $conn->insert('into notify ...');

    $tran->commit();
    return $id;
  } catch (SQLException $e) {
    $tran->rollback();
    throw $e;
  }
}
```

*Note: Not all database systems support transactions, and of those that do, not all support nested transactions. Be sure to read the manual pages of the RDBMS you are accessing.*

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance58

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 84.1% 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 ~57 days

Recently: every ~316 days

Total

69

Last Release

276d ago

Major Versions

v10.2.0 → v11.0.02018-07-15

v11.0.0 → v12.0.02018-08-24

7.0.0.x-dev → v8.0.42018-12-21

8.0.0.x-dev → v12.0.22019-12-01

v12.0.3 → v13.0.02020-04-10

PHP version history (4 changes)v6.0.0PHP &gt;=5.4.0

v6.5.0PHP &gt;=5.5.0

v9.0.0PHP &gt;=5.6.0

v13.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (14638 commits)")[![kiesel](https://avatars.githubusercontent.com/u/127769?v=4)](https://github.com/kiesel "kiesel (2395 commits)")[![ohinckel](https://avatars.githubusercontent.com/u/717217?v=4)](https://github.com/ohinckel "ohinckel (335 commits)")[![Stormwind](https://avatars.githubusercontent.com/u/836872?v=4)](https://github.com/Stormwind "Stormwind (13 commits)")[![treuter](https://avatars.githubusercontent.com/u/1067905?v=4)](https://github.com/treuter "treuter (6 commits)")[![kusnier](https://avatars.githubusercontent.com/u/726429?v=4)](https://github.com/kusnier "kusnier (5 commits)")[![johannes85](https://avatars.githubusercontent.com/u/470531?v=4)](https://github.com/johannes85 "johannes85 (5 commits)")[![andstefiul](https://avatars.githubusercontent.com/u/798415?v=4)](https://github.com/andstefiul "andstefiul (5 commits)")[![beorgler](https://avatars.githubusercontent.com/u/2027220?v=4)](https://github.com/beorgler "beorgler (3 commits)")[![ppetermann](https://avatars.githubusercontent.com/u/69334?v=4)](https://github.com/ppetermann "ppetermann (1 commits)")[![guel1973](https://avatars.githubusercontent.com/u/4669852?v=4)](https://github.com/guel1973 "guel1973 (1 commits)")

---

Tags

mssqlmysqlphppostgresqlrdbmssqlite3sybasetdstransactionxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-rdbms/health.svg)

```
[![Health](https://phpackages.com/badges/xp-framework-rdbms/health.svg)](https://phpackages.com/packages/xp-framework-rdbms)
```

PHPackages © 2026

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