Download the PHP package a1phanumeric/php-mysql-class without Composer
On this page you can find all versions of the php package a1phanumeric/php-mysql-class. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-mysql-class
PHP MySQL Class (PDO)
A production-oriented PDO helper for PHP applications that need a small, dependency-free database abstraction with prepared statements, transaction helpers, and predictable error handling.
Highlights
- PDO-first API with prepared statements by default
- Works with MySQL/MariaDB and Microsoft SQL Server
- Safe defaults for modern workloads:
PDO::ERRMODE_EXCEPTIONPDO::ATTR_EMULATE_PREPARES = false(MySQL)- UTF-8 (
utf8mb4) MySQL charset by default
- Optional connection singleton keyed per connection config
- Transaction helpers (
beginTransaction,commit,rollBack,transaction) - Query execution helpers (
execute,fetch,fetchAll) - Optional query logger for observability and diagnostics
Installation
Requirements
- PHP
>=7.4 ext-pdo- For MySQL:
ext-pdo_mysql - For SQL Server:
ext-sqlsrv
Quick Start
Usage
1) Standard queries
2) Fetch a single row
3) Fetch many rows
4) Key fetchAll by a column
5) Transactions (recommended for multi-step writes)
6) Singleton connection (per unique connection configuration)
7) Connection options
SQL Server example:
8) Diagnostics and observability
If a query fails, inspect:
API Reference
execute(string $query, $values = null, bool $debug = false): PDOStatement|falsefetch(string $query, $values = null): ?arrayfetchAll(string $query, $values = null, ?string $key = null): arraytable_exists(string $table): boolbeginTransaction(): boolcommit(): boolrollBack(): boolinTransaction(): booltransaction(Closure $callback)lastInsertId(): stringgetPdo(): ?PDOgetLastError(): ?stringsetQueryLogger(callable $logger): self
Backward Compatibility Notes
- Existing constructor usage continues to work.
- Existing
execute,fetch, andfetchAllmethod names remain unchanged. execute(..., $debug = true)is deprecated and should be replaced withsetQueryLogger().- Singleton behavior is now safer for multi-database apps: each unique connection configuration gets its own instance.
Security Notes
- Always use placeholders with bound parameters for user input.
- Avoid persistent connections unless you have validated behavior under your workload.
- Enable TLS/secure transport for SQL Server (
encrypt => true) in production.
Releasing / Tagging for Packagist
Packagist picks up new versions from Git tags.
- Update docs/changelog for the release.
- Commit and push to your default branch.
-
Tag using semantic versioning.
- Ensure your Packagist package auto-update webhook is configured, or trigger an update manually in Packagist.
Recommended versioning for these changes: major release (v3.0.0) for a clean SemVer boundary on the upgraded production behavior and API surface.
Legacy Class
The legacy class is still included in this repository:
class.MySQL.phpclass.MySQL.README.md
License
MIT
All versions of php-mysql-class with dependencies
ext-pdo Version *