Download the PHP package jdz/database without Composer

On this page you can find all versions of the php package jdz/database. 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 database

JDZ Database

A developer-friendly database abstraction layer for PHP 8.2+ applications.

Unified Interface - Write once, run anywhere. Switch between MySQL, PostgreSQL, and SQLite without changing your code.

Type-Safe - Built with PHP 8.2+ features including enums, typed properties, and strict types for reliability.

Developer-Friendly - Fluent query builder, intuitive methods, and comprehensive error handling make database operations straightforward.

Production-Ready - Thoroughly tested with 200+ unit and integration tests covering all drivers and features.

Flexible - Use query builders for type safety or raw SQL when you need full control. Mix and match as needed.

Installation

Requirements

Required Extensions (install as needed)

Check Available Drivers: The library includes methods to detect which drivers are available on your system.

Configuration Options

Common Options

Connection Options (MySQL, PostgreSQL)

SQLite Options

MySQLi Options

Supported Database Drivers

PDO-Based Drivers

Native Drivers

All drivers share the same interface, making it easy to switch between them or support multiple databases in the same application.

Core Features

Database Operations

Query Building

Advanced Features

How It Works

Database Factory Pattern

The library uses a factory pattern to create database instances. You can instantiate databases from configuration arrays or DSN strings, with automatic driver selection based on your environment. The factory also provides methods to check available drivers on your system.

Query Builder Architecture

Instead of writing raw SQL strings, you can use dedicated query builder classes. Each query type (SELECT, INSERT, UPDATE, DELETE, UNION) has its own builder with methods corresponding to SQL clauses. Builders use method chaining for a fluent interface and maintain type safety through PHP's type system.

Connection Management

Database connections are lazy-loaded and managed automatically. The library handles connection state, automatic reconnection on failure, and proper resource cleanup. You can check connection status, manually connect/disconnect, and manage multiple database connections simultaneously.

Parameter Binding

All queries support parameter binding to prevent SQL injection. Named parameters (:name) and typed parameters are supported. The ParamType enum provides type hints (INT, STR, BOOL, NULL, LOB) for proper data handling across different database engines.

Data Loading Methods

Results can be loaded in various formats:

Table Prefix System

Use #__ as a placeholder in table names, which gets replaced with your configured prefix. This allows writing portable code that works across different installations with different prefixes.

Query Builders

SelectQuery Builds SELECT statements with full SQL feature support. Chain methods to add columns, specify tables, add WHERE conditions, JOIN other tables, group results, filter groups with HAVING, order results, and limit/offset for pagination. Supports complex nested queries and all JOIN types (INNER, LEFT, RIGHT, CROSS).

InsertQuery Constructs INSERT statements supporting two syntaxes: VALUES (traditional column/value pairs) and SET (key=value pairs). Handles single or multiple row insertion, INSERT IGNORE for duplicate handling, and parameter binding for all values. Returns insert ID after execution.

UpdateQuery Builds UPDATE statements with SET clause for field updates. Supports WHERE conditions for targeting specific rows, JOIN for updating based on related tables, ORDER BY for controlling update order, and LIMIT for restricting update count. All values support parameter binding.

DeleteQuery Creates DELETE statements with WHERE conditions for row targeting, JOIN support for deleting based on related tables, ORDER BY for deletion order control, and LIMIT for restricting deletion count. Ensures safe deletions through parameter binding.

UnionQuery Combines multiple SELECT queries using UNION (remove duplicates) or UNION ALL (keep duplicates). Each subquery can be a SelectQuery object or raw SQL string. Supports ORDER BY and LIMIT on the combined result set. Useful for merging data from multiple tables or queries.

StringQuery Wraps raw SQL strings when you need full control. Still supports parameter binding for security. Useful for complex queries, database-specific features, or when query builders don't cover your use case. Integrates seamlessly with the database instance.

Database Introspection

The library provides methods to inspect database structure and metadata:

Table Operations

Column Information

Database Metadata

Transaction Handling

Transactions ensure data consistency across multiple operations. Start a transaction with transactionStart(), execute your queries, then either transactionCommit() to save changes or transactionRollback() to undo them. PostgreSQL supports savepoints for fine-grained control within transactions.

Examples

The examples/ directory contains comprehensive, runnable examples demonstrating all library features.

Run examples

Notes

Testing

The library includes a comprehensive test suite with 200+ unit and integration tests covering all drivers and features.

Running Tests

Tests automatically start/stop Docker containers for MySQL and PostgreSQL, ensuring consistent test environments.

Test Coverage

Unit Tests (no database required)

Query Builder Tests

What's Tested

Core Database Functionality

Driver-Specific Features

Factory & Configuration

License

MIT License - Free for personal and commercial use. See LICENSE file for full text.


All versions of database with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 jdz/database contains the following files

Loading the files please wait ...