1. Go to this page and download the library: Download blackcube/active-record library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class ProductQuery extends ActiveQuery implements ScopableQueryInterface
{
use ScopableTrait;
use QualifyColumnTrait;
}
$products = Product::query()
->active(active: false)
->language(languageId: 'fr')
->andWhere(['like', 'title', 'laptop'])
->all();
class Article extends ActiveRecord implements ElasticInterface
{
use ElasticTrait; // handles __get/__set dispatch, no MagicCompose needed
}
// Properties come from JSON Schema, not PHP class definition
$article->author = 'Philippe'; // stored in _extras JSON column
$article->rating = 5;
$article->save();
// Query virtual columns — automatically converted to JSON_VALUE()
$top = Article::query()->where(['>', 'rating', 3])->orderBy(['rating' => SORT_DESC])->all();
// Validation from JSON Schema
$resolver = new ElasticRuleResolver();
$rules = $resolver->resolve($article);
class Menu extends ActiveRecord implements HazeltreeInterface
{
use HazeltreeTrait; // handles __get/__set dispatch, no MagicCompose needed
}
// Write
$home = new Menu(); $home->name = 'Home'; $home->save(); // path: 1
$about = new Menu(); $about->name = 'About'; $about->saveInto($home); // path: 1.1
$blog = new Menu(); $blog->name = 'Blog'; $blog->saveAfter($about); // path: 1.2
// Read — one query each
$children = $home->relativeQuery()->children()->all();
$breadcrumb = $about->relativeQuery()->parent()->
class Content extends ActiveRecord implements ElasticInterface, HazeltreeInterface
{
use HazeltreeElasticTrait; // dispatches to both, resolves all collisions
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.