Search by

entidi / silverstripe-logobject

ntd

A DataObjectInterface for storing data using the archive engine of MariaDB/MySQL

Package info

github.com/ntd/silverstripe-logobject

Type:silverstripe-vendormodule

pkg:composer/entidi/silverstripe-logobject

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-28 18:16 UTC

This package is auto-updated.

Last update: 2026-10-28 18:25:25 UTC


README

Having immutable tables can be useful in many situations, e.g. with logs or GDPR specific requirements. MySQL and MariaDB provide the ARCHIVE engine which seems well suited for this purpose.

Unfortunately, Silverstripe's DataObject class cannot be used directly with this engine. Silverstripe relies on several $fixed_fields and database indexes that are tightly coupled to its implementation and cannot easily be disabled or customized.

This module provides a dedicated DataObjectInterface for log records, designed to work with the ARCHIVE storage engine. It enforces restrictions that make sense for append-only logs such as:

  • cannot delete or update existing rows
  • no $fixed_fields apart from ID
  • no indexes
  • no relations or foreign keys support
  • no inheritance complexity: subclasses do not merge fields with the parent classes

License

See License.

This module template defaults to using the "BSD-3-Clause" license. The BSD-3 license is one of the most permissive open-source license and is used by most Silverstripe CMS module.

Installation

composer require entidi/silverstripe-logobject

Documentation

Just use LogObject instead of DataObject, e.g.:

use eNTiDi\LogObject\LogObject;
use SilverStripe\ORM\FieldType\DBDatetime;

class MyLog extends LogObject
{
    private static $table_name = 'MyLog';

    // The `ID` primary key is (always) automatically created
    private static $db = [
        'Created' => 'Datetime',
        'Facility' => "Enum('Auth,Cron,FTP,Mail')",
        'Level' => "Enum('Debug,Info,Warning,Error')",
        'Message' => 'Varchar(200)',
        'PID' => 'Int',
    ];
}

// Save a new row
$log = MyLog::create([
    'Created' => DBDatetime::now(),
    'Level' => 'Debug',
]);
$log->setField('Facility', 'FTP');
$log->Message = 'Some message here...';
$log->PID = 123;
$id = $log->write();