polyfills/pdo-sqlite-subclass

User-land PHP polyfill for PDO Sqlite driver subclass.

dev-main 2024-01-14 19:08 UTC

This package is auto-updated.

Last update: 2024-11-14 21:04:16 UTC


README

Latest Stable Version License PHP Version Require CI

Provides user-land PHP polyfills for the Sqlite subclass provided by PHP 8.4.

Supports PHP 8.1, 8.2, and 8.3. On PHP 8.4 and later, this polyfill is not necessary. Requires pdo_sqlite extension.

It is possible and safe to require this polyfill on PHP 8.4 and later. This polyfill class is autoloadable; on PHP 8.4 and later, PHP will not autoload this polyfill because it's declared natively.

For more information, see PdoSqlite on PHP 8.4: PDO Driver-specific sub-classes: Sqlite

Installation

composer require polyfills/pdo-sqlite-subclass

Usage

Use the provided PdoMysql class to replace PDO MySQL connections.

$sqliteConnection = new PdoMysql(
    'sqlite:host=localhost;dbname=phpwatch;charset=utf8mb4;port=33066',
    '<username>',
    '<password>',
);
$sqliteConnection = PdoMysql::connect(
    'sqlite:host=localhost;dbname=phpwatch;charset=utf8mb4;port=33066',
    '<username>',
    '<password>',
);

This polyfill adds class-constants to PdoSqlite class to match all of the PDO::MYSQL_ constants. For example, PDO::MYSQL_ATTR_SSL_CERT is identical to PdoMysql::ATTR_SSL_CERT.

Features not implemented

  • PDO::connect: This method cannot be polyfilled because it's an existing PHP class that user-land PHP classes cannot modify.

Contributions

Contributions are welcome either as a GitHub issue or a PR to this repo.