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 lightweight, framework-agnostic PHP database library providing a unified API across MySQL, MariaDB, PostgreSQL, SQLite, Microsoft SQL Server (MSSQL), and Oracle.

Built on top of PDO with zero external dependencies, it offers:

Core Features:

Performance:

Advanced Features:

Developer Experience:

Production Ready:

Additional Capabilities:

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


Why PDOdb?

Perfect for:

vs. Raw PDO:

vs. Eloquent/Doctrine:


Table of Contents


Requirements

Check if your SQLite has JSON support:


Installation

Install via Composer:

For specific versions:

Quick Setup with pdodb init

Fastest way to get started: Use the interactive wizard to configure your project:

The wizard will guide you through:

See CLI Tools Documentation for more details.


📖 Documentation

Complete documentation is available in the documentation/ directory with 56+ detailed guides covering all features:

Each guide includes working code examples, dialect-specific notes, security considerations, and best practices.

Start here: Documentation Index

📚 Examples

Comprehensive, runnable examples are available in the examples/ directory:

Each example is self-contained with setup instructions. See examples/README.md for the full catalog.

Quick start:


Quick Example

Fastest start: Run vendor/bin/pdodb init for interactive setup, or get started manually:

That's it! No configuration, no dependencies, just works.


5-Minute Tutorial

Step 1: Install

Step 2: Initialize Project

Use the interactive wizard:

Alternative: Manual configuration

Step 3: Create Table

Step 4: CRUD Operations

Step 5: Monitor Your Database

Launch the interactive TUI Dashboard to monitor your database in real-time:

Monitor active queries, connection pool, cache statistics, and server metrics. Press h for help, q to quit.

Next: See Quick Start for more examples.


Configuration

Basic Configuration

Advanced Configuration

Connection Pooling:

Read/Write Splitting:

Query Caching:

See Configuration Documentation for complete configuration options.


Quick Start

Note: All query examples start with $db->find() which returns a QueryBuilder instance.

🤖 AI-Powered Query Analysis

Get intelligent optimization recommendations for your queries using AI:

Or use CLI:

Supported Providers: OpenAI, Anthropic, Google, Microsoft, DeepSeek, Yandex, Ollama (local, no API key)

Model Selection: Configure models via environment variables (PDODB_AI_<PROVIDER>_MODEL) or config array (ai.providers.<provider>.model)

See AI Analysis Documentation for complete guide.

Basic CRUD Operations

Filtering and Joining

Transactions

See Query Builder Documentation for more examples.


JSON Operations

PDOdb provides a unified JSON API that works consistently across all databases.

See JSON Operations Documentation for complete guide.


Advanced Usage

Raw Queries

Subqueries

Pagination

Batch Processing

Query Caching

See Advanced Features Documentation for complete guide.


CLI Tools

PDOdb provides convenient command-line tools for common development tasks:

🖥️ Interactive TUI Dashboard

Monitor your database in real-time with a beautiful full-screen terminal interface:

Features:

Perfect for debugging, monitoring production databases, understanding query patterns, and managing database schema.

Available Commands

Bash Completion

Install bash completion for enhanced CLI experience:

Examples

See CLI Tools Documentation for complete guide.


Error Handling

PDOdb provides a comprehensive exception hierarchy for better error handling:

All exceptions extend PDOException for backward compatibility and provide rich context information.

See Error Handling Documentation for complete guide.


Performance Tips

Enable Query Caching

For applications with repeated queries, enable result caching:

Performance Impact: 65-97% faster for repeated queries with cache hits.

Use Batch Operations

Always Limit Result Sets

Use Batch Processing for Large Datasets

See Performance Documentation for more tips.


Helper Functions

PDOdb provides 80+ helper functions for common SQL operations:

Core Helpers:

String Operations:

Numeric Operations:

Date/Time Functions:

JSON Operations:

Aggregate Functions:

Full Reference: See Helper Functions Documentation for complete list and examples.


API Reference

PdoDb Main Class

Method Description
find() Returns QueryBuilder instance
rawQuery(string, array) Execute raw SQL, returns array of rows
rawQueryOne(string, array) Execute raw SQL, returns first row
startTransaction() Begin transaction
commit() Commit transaction
rollBack() Roll back transaction
describe(string) Get table structure
indexes(string) Get all indexes for a table
keys(string) Get foreign key constraints

QueryBuilder Methods

Table & Selection:

Filtering:

Data Manipulation:

Execution:

Full Reference: See API Reference Documentation for complete method list and signatures.


Dialect Differences

PDOdb handles most differences automatically, but here are some key points:

UPSERT:

Use onDuplicate() for portable UPSERT:

JSON Functions:

All handled transparently through Db::json*() helpers.

Full Reference: See Dialect Differences Documentation for complete guide.


Frequently Asked Questions

Is PDOdb an ORM?

No, PDOdb is a query builder with optional ActiveRecord pattern. It's lighter than full ORMs like Eloquent or Doctrine.

Can I use raw SQL?

Yes! Use rawQuery() for complete control:

Does it work with frameworks?

Yes! PDOdb is framework-agnostic. Works with Laravel, Symfony, Yii, or no framework at all.

Is it production-ready?

Yes! 3806+ tests, 12180+ assertions, PHPStan level 8, used in production environments.

What about security?

All queries use prepared statements automatically. SQL injection protection is built-in.

Can I use it with existing PDO connections?

Yes! Pass your PDO instance:

Which database should I use for development?

SQLite is perfect for development - no server setup needed:

Does it support transactions?

Yes! Full transaction support with savepoints:


Migration Guide

From Raw PDO

Before:

After:

From Eloquent (Laravel)

Before:

After:

See Migration Guide Documentation for more examples.


Troubleshooting

"Driver not found" Error

Solution: Install the required PHP extension:

"JSON functions not available" (SQLite)

Solution: Check if JSON support is available:

"SQLSTATE[HY000]: General error: 1 near 'OFFSET'"

Problem: Using OFFSET without LIMIT in SQLite.

Solution: Always use LIMIT with OFFSET:

Memory Issues with Large Result Sets

Solution: Use batch processing or streaming:

See Troubleshooting Documentation for more solutions.


Testing

The project includes comprehensive PHPUnit tests for all supported databases.

Running Tests

Test Requirements


Contributing

Contributions are welcome! Please follow these guidelines:

  1. Open an issue first for new features or bug reports
  2. Include failing tests that demonstrate the problem
  3. Follow PSR-12 coding standards
  4. Write tests for all new functionality
  5. Test against all six dialects (MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, Oracle)

Pull Request Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is open source. See LICENSE file for details.


Acknowledgments

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

Built with ❤️ for the PHP community.


All versions of pdo-database-class with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-pdo 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 ...