PHPackages                             byjg/anydataset-db - 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. byjg/anydataset-db

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

byjg/anydataset-db
==================

AnyDataset-DB provides a relational database abstraction layer. It is part of the Anydataset project, an agnostic data source abstraction layer for PHP.

6.0.0(5mo ago)581.4k↓25.3%54MITPHPPHP &gt;=8.3 &lt;8.6CI passing

Since Nov 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/byjg/php-anydataset-db)[ Packagist](https://packagist.org/packages/byjg/anydataset-db)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-anydataset-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (27)Used By (4)

   sidebar\_key anydataset-db   tags    php

 anydataset

 databases

    Database Abstraction Layer
==========================

[](#database-abstraction-layer)

**AnyDataset-DB** provides a relational database abstraction layer. It is part of the Anydataset project, an agnostic data source abstraction layer for PHP.

[![Sponsor](https://camo.githubusercontent.com/fab14b7f7f475072ada0473f193d6f322561fd4a2958e0cc89910d053347cf27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2532336561346161613f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d306431313137)](https://github.com/sponsors/byjg)[![Build Status](https://github.com/byjg/php-anydataset-db/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-anydataset-db/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-anydataset-db/)[![GitHub license](https://camo.githubusercontent.com/7b85326d4ad8142da2c3ad7104891567e1dc3c6dab1884946b5c45b753c97f46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d616e79646174617365742d64622e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/166c69f414e690f8f2e0dd995762df8e659bb0315eef1cf852a95b9dce086c4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d616e79646174617365742d64622e737667)](https://github.com/byjg/php-anydataset-db/releases/)

Learn more about Anydataset [here](https://opensource.byjg.com/anydataset).

Features
--------

[](#features)

- Connection based on URI
- Handles compatibility and code optimization across multiple databases (e.g., MySQL, PostgreSQL, MS SQL Server)
- Built-in Query Cache support using a PSR-16 compliant interface
- Enables connection routing based on regular expressions for queries (e.g., directing queries to different databases for specific tables)

Connection Based on URI
-----------------------

[](#connection-based-on-uri)

Database connections are defined using URL-based connection strings.

Supported drivers are listed below:

DatabaseConnection StringFactory MethodSQLitesqlite:///path/to/file`getDbInstance()`MySQL/MariaDBmysql://username:password@hostname:port/database`getDbInstance()`PostgreSQLpsql://username:password@hostname:port/database`getDbInstance()`SQL Server (DbLib)dblib://username:password@hostname:port/database`getDbInstance()`SQL Server (Sqlsrv)sqlsrv://username:password@hostname:port/database`getDbInstance()`Oracle (OCI8)oci8://username:password@hostname:port/database`getDbInstance()`Generic PDOpdo://username:password@pdo\_driver?PDO\_PARAMETERS`getDbInstance()`Example usage:

```
