Bit Badger Documents PHP implementation with PDO
Go to file
Daniel J. Summers df436c9ef4 Changes for RC1 (#6)
- `ORDER BY` clauses support qualified fields
- Restrict supported PHP versions; this will prevent inadvertent upgrades to the upcoming 8.4-compliant version

Reviewed-on: #6
2024-10-01 00:29:12 +00:00
src Changes for RC1 (#6) 2024-10-01 00:29:12 +00:00
tests Changes for RC1 (#6) 2024-10-01 00:29:12 +00:00
.gitattributes Exclude tests and other files 2024-06-09 20:50:43 -04:00
.gitignore Add PostgreSQL Support (#3) 2024-06-21 13:46:41 +00:00
composer.json Changes for RC1 (#6) 2024-10-01 00:29:12 +00:00
composer.lock Changes for RC1 (#6) 2024-10-01 00:29:12 +00:00
LICENSE Initial commit 2024-06-03 23:07:15 +00:00
README.md Update README for doc changes 2024-07-22 11:10:33 -04:00

PDODocument

This library allows SQLite and PostgreSQL to be treated as document databases. It is a PHP implementation of the .NET BitBadger.Documents library.

Add via Composer

Packagist Version

composer require bit-badger/pdo-document

Configuration

Connection Details

The PDO data source name must be provided via Configuration::useDSN(). Configuration also has $username, $password, and $options variables that will be used to construct the PDO object it will use for data access.

Document Identifiers

Each document must have a unique identifier. By default, the library assumes that this is a property or array key named id, but this can be controlled by setting Configuration::$idField. Once documents exist, this should not be changed.

IDs can be generated automatically on insert. The AutoId enumeration has 4 values:

  • AutoId::None is the default; no IDs will be generated
  • AutoId::Number will assign max-ID-plus-one to documents with an ID of 0
  • AutoId::UUID will generate a v4 UUID for documents with an empty string ID
  • AutoId::RandomString will generate a string of letters and numbers for documents with an empty string ID; Configuration::$idStringLength controls the length of the generated string, and defaults to 16 characters

In all generated scenarios, if the ID value is not 0 or blank, that ID will be used instead of a generated one.

Usage

Full documentation is available on the project site.