deemru/triples

Simple SQLite layer

1.0.10 2024-07-26 10:00 UTC

This package is auto-updated.

Last update: 2024-11-26 10:49:00 UTC


README

packagist php-v GitHub codacy license

Triples implements a simple flexible layer for SQLite storage.

  • Speed
  • Merge through cache
  • Custom queries

Usage

$dbpath = __DIR__ . '/triples.sqlite';
$triples = new Triples( $dbpath, 'triples', true, [ 'INTEGER PRIMARY KEY', 'TEXT UNIQUE', 'INTEGER' ], [ 0, 0, 1 ] );

$r0 = 1;
$r1 = 'Hello, World!';
$r2 = crc32( $r1 );
$rec = [ $r0, $r1, $r2 ];
$recs = [ $rec ];
$triples->merge( $recs );

if( $triples->getUno( 2, $r2 )[0] != $r0 ||
    $triples->getUno( 1, $r1 )[2] != $r2 ||
    $triples->getUno( 0, $r0 )[1] !== $r1 )
    exit( 1 );

Requirements

Installation

Require through Composer:

{
    "require": {
        "deemru/triples": "1.0.*"
    }
}