hizzle/store

A standardized way of creating data stores for your projects

Installs: 350

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 1

pkg:composer/hizzle/store

0.2.15 2025-11-06 07:39 UTC

README

This is currently in Beta so expect the API to change alot.

Features

  • CRUD Operations: Create, read, update, and delete records
  • Query Builder: Powerful query builder with filtering, sorting, and pagination
  • Aggregate Functions: Support for SUM, AVG, COUNT, MIN, MAX with grouping
  • JOIN Queries: Relate collections together for complex data analysis
  • REST API: Automatic REST API endpoints for all collections
  • Meta Fields: Support for custom meta fields with multiple values
  • Custom Post Types: Integrate with WordPress custom post types

Quick Start

Basic Usage

use Hizzle\Store\Store;

// Initialize a store
Store::init('my_store', array(
    'customers' => array(
        'name' => 'customers',
        'singular_name' => 'customer',
        'props' => array(
            'id' => array(
                'type' => 'int',
                'length' => 20,
                'nullable' => false,
            ),
            'name' => array(
                'type' => 'varchar',
                'length' => 255,
                'nullable' => false,
            ),
            'email' => array(
                'type' => 'varchar',
                'length' => 255,
                'nullable' => false,
            ),
        ),
        'keys' => array(
            'primary' => 'id',
        ),
    ),
));

JOIN Queries (New!)

Define relationships between collections:

'customers' => array(
    // ... other config
    'joins' => array(
        'payments' => array(
            'collection' => 'my_store_payments',
            'on' => 'id',
            'foreign_key' => 'customer_id',
            'type' => 'LEFT',
        ),
    ),
)

Use JOINs in aggregate queries:

$query = $collection->query(array(
    'join' => array('payments'),
    'aggregate' => array(
        'payments.amount' => array('SUM', 'COUNT'),
    ),
    'groupby' => 'id',
));

Documentation

Requirements

  • PHP >= 5.3.0
  • WordPress (for REST API and database integration)