Download the PHP package tommyknocker/pdo-database-class without Composer

On this page you can find all versions of the php package tommyknocker/pdo-database-class. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdo-database-class

PDOdb

PHP Version Latest Version Tests PHPStan Level 8 Coverage Downloads GitHub Stars

PDOdb is a PHP database library for MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, and Oracle. You write queries once with a fluent builder. When a query is slow, one call sends the available execution plan, columns, and indexes to a provider you choose, so you can review a suggestion without pasting the schema into chat.

Built on PDO, with no framework dependency. The package requires three PSR interfaces: psr/log, psr/simple-cache, and psr/event-dispatcher.

To try it with SQLite, install PHP 8.4+ with pdo_sqlite, then run:

Rows are associative arrays by default. asObject() returns stdClass objects instead:

Why PDOdb

Compared with raw PDO. Queries are method calls, parameters are bound for you, and helpers cover dates, JSON, aggregates, and strings. The SQL that reaches the server still follows that database's dialect.

Compared with Eloquent or Doctrine. There is no framework to adopt and no ORM unless you want the optional ActiveRecord layer. You can drop to raw SQL. Two things those libraries do not include: query advice grounded in the database plan, and a terminal dashboard for a connection you have already configured.

Several databases in one project. The same builder calls target MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, and Oracle. Where the SQL itself differs, the dialect guide says so.

Understand a slow query with your model

You already know which query is slow. The open question is whether to change a filter, a join, an index, or nothing. Start with the plan PDOdb can read. That call does not use a network.

A full scan plus a temporary sort suggests an index on the filter columns, then the sort columns. When that index already exists, the advice says a new one is not indicated. SQL Server does not expose a verified plan through PDO, and a parameterized Oracle EXPLAIN is unavailable. Those results say the plan is missing. They do not invent one.

When you want an explanation of that same query, send the collected plan to your model:

PDOdb collects the available plan, the columns, and the existing indexes, then makes one request to the provider configured for your application. You get an explanation and a hypothesis. PDOdb does not create the index or run the model's SQL. Details: query-advice limitations.

On the included SQLite fixture the plan before a matching index looked like this:

After the index was applied in that fixture, the same ordered page used the index:

The median SELECT on that synthetic database moved from 4.6860 ms to 0.0200 ms. That is a local measurement of the fixture, not a production promise. A third case in the same demo needs no new index: the existing one already matches the filter and the order. Walkthrough, setup, and the three cases: Understand and improve a query with AI.

In an application. Call explainAiAdvice() on the PdoDb instance you already use. Put the provider, key, and model in that process environment. Configuration reference.

Offline demo, no API key. A Composer installation places the package under vendor/tommyknocker/pdo-database-class/; it does not create examples/ in your project root. To run the demo from a repository checkout, use:

The command builds 100,000 synthetic orders in memory, prints real SQLite plans, and checks that each reviewed index change preserves the result.

Capabilities

Each item below is implemented in the library and documented on its own page.

Queries

Writes and schema

Speed and scale

Application code

Tools

Work with JSON the same way on every database

The helper calls stay the same. Each dialect receives its own JSON SQL.

More JSON operations: create and query JSON.

Requirements

Database test coverage

CI runs the database suites against:

Database CI version
MySQL 8.0
MariaDB 11.2
PostgreSQL 16
SQLite Runner's bundled version
SQL Server 2022
Oracle XE 21

SQLite JSON support:

1 means JSON is available.

Installation

vendor/bin/pdodb init writes a connection config (.env or config/db.php) and can create migration and model directories. Full option list: configuration.

Documentation and examples

Start with the hello world.

Find methods in the dialect differences.

Coming from raw PDO or Eloquent: troubleshooting.

The examples are included under vendor/tommyknocker/pdo-database-class/examples/ in the Composer package and are also available in a repository checkout. Example catalog.

To check all examples on the available databases, also from the repository root:

Frequently Asked Questions

Is PDOdb an ORM? It is a query builder with an optional ActiveRecord layer.

Can I use raw SQL? Yes. Use rawQuery() or the raw SQL API.

Can I use it with a framework? Yes. PDOdb has no framework dependency and can be used in an existing PHP application.

Does it support transactions? Yes, including savepoints for nested transactions. See transactions.

Testing

MySQL and MariaDB expect a server on localhost:3306, PostgreSQL on 5432, SQL Server on 1433, and Oracle on 1521 (pdo_oci and Oracle Instant Client). SQLite uses :memory:.

Contributing

Open an issue before a new feature, follow PSR-12, and add tests. Dialect-specific behavior belongs in that dialect's test directory. See CONTRIBUTING.md.

Development and CI use composer install so PHPStan and the other development tools follow composer.lock. The lock file does not constrain applications that require PDOdb as a package. Update dependencies with composer update and include the lock file in that change.

License

MIT. See LICENSE.

Acknowledgments

Inspired by ThingEngineer/PHP-MySQLi-Database-Class and the Yii2 framework.


All versions of pdo-database-class with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-pdo Version *
ext-mbstring Version *
psr/log Version ^3.0
psr/simple-cache Version ^3.0
psr/event-dispatcher Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tommyknocker/pdo-database-class contains the following files

Loading the files please wait ...