Download the PHP package amund/pdo-silo without Composer
On this page you can find all versions of the php package amund/pdo-silo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package pdo-silo
PDO-Silo
A silo to store and link resources, via a simple API.
License: MIT
PHP: 8.1+
Drivers: MySQL, SQLite, PostgreSQL
Installation
Quick Overview
API
Silo lifecycle
| Method | Description |
|---|---|
__construct(\PDO $pdo, string $prefix = 'resource') |
Create a Silo instance. |
create(): void |
Create the 4 database tables (PREFIX_meta, PREFIX_attribute, PREFIX_link, PREFIX_cache) |
destroy(): void |
Drop all 4 tables |
Resources
| Method | Description |
|---|---|
set(string $class, array $attributes = [], bool $get = false): int\|array |
Create a resource. Returns its id (or full resource if $get is true). |
get(int $id, bool $links = false, bool $getLinks = false): ?array |
Retrieve a resource by id. Optionally include its links. |
getMeta(int $id): ?array |
Returns ['id', 'class'] or null. |
setMeta(?int $id, string $class): int |
Create ($id = null) or update a resource class. Returns the resource id. |
getAttr(int $id, string $attr): ?string |
Returns the attribute value, or null. |
setAttr(int $id, string $attr, mixed $value): mixed |
Set/update/delete an attribute. null and '' delete the attribute. '0' and 0 are stored. |
getAttributes(int $id): array |
Returns all attributes as ['name' => 'value', ...]. |
setAttributes(int $id, ?array $attributes): ?array |
Replace all attributes, or pass null to delete them all. |
Links
| Method | Description |
|---|---|
link(int $from, int $to, ?string $attribute = null): bool |
Create a link. Default attribute = target class name. |
unlink($from, $to): bool |
Remove a specific link, all links from, all links to, or all links for an id. |
linkFrom(int $id, bool $get = false): array |
Get child links, grouped by attribute. |
linkTo(int $id, bool $get = false): array |
Get parent links, grouped by attribute. |
getList(int $parent, string $attribute): array |
Get an ordered list of linked resources (by position). |
setList(int $parent, string $attribute, array $children): void |
Replace an ordered list. |
listFrom(int $id, bool $get = false): array |
Get list children, grouped by attribute. |
listTo(int $id, bool $get = false): array |
Get list parents, grouped by attribute. |
Search
| Method | Description |
|---|---|
search(array $arg = [], bool $get = false, bool $links = false, bool $getLinks = false): array |
Search resources. Returns ['total', 'results', 'duration']. Supports where, order, limit, and offset keys. |
filter(string $field, string $operator, string\|int\|float\|array $value): string |
Build a WHERE clause fragment. Operators: =, !=, <, >, <=, >=, LIKE, IN. int/float values produce numeric comparisons. |
group(string $operator, string ...$filters): string |
Combine filters with AND or OR. |
Cache
| Method | Description |
|---|---|
emptyCache(): void |
Clear all cached resources. |
Running Tests
Tests use SQLite :memory:. Each test creates and destroys its own silo.
Static Analysis
Requirements
- PHP 8.1 or higher
ext-pdo(required)ext-pdo_mysql(for MySQL),ext-pdo_sqlite(for SQLite), orext-pdo_pgsql(for PostgreSQL)
About
The idea behind PDO-Silo is to provide a minimal persistence layer for PHP projects — a nano ORM / DBAL. It is simple, small, fast, and fun to use.
Built by Dimitri Avenel. Originally created in 2016.
All versions of pdo-silo with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
ext-pdo Version *
ext-pdo Version *
The package amund/pdo-silo contains the following files
Loading the files please wait ...