View chunk_migrate.php
<?php
public function migrate(Chunk $chunk, Shard $dstShard, array $schemas)
{
$shardId = $chunk->getShardId();
if ($dstShard->id === $shardId) {
throw new InvalidArgumentException("{$dstShard->id} == $shardId");
}
try {
View queryAPI.php
<?php
public function testRepoFetchColumn()
{
$this->assertResultSuccess(Book::create([ 'title' => 'Book 1' ]));
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
// create one book with duplicated title
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
View Sharding_OrderModel_loadByKeys.php
<?php
/**
* An alias for BaseRepo::loadByKeys
*/
protected static function loadByKeys(array $args, $byKeys = null)
{
if (static::SHARD_MAPPING_ID) {
return static::shards()->first(function(BaseRepo $repo, Shard $shard) use ($arg, $byKeys) {
return $repo->loadByKeys($args, $byKeys);
View AuthorBase.php
<?php
namespace AuthorBooks\Model;
require_once __DIR__ . '/AuthorSchemaProxy.php';
use Maghead\Schema\SchemaLoader;
use Maghead\Result;
use Maghead\Inflator;
use SQLBuilder\Bind;
use SQLBuilder\ArgumentArray;
use SQLBuilder\Universal\Query\InsertQuery;
use SQLBuilder\Driver\BaseDriver;
View AuthorBaseRepo.php
<?php
namespace AuthorBooks\Model;
require_once __DIR__ . '/AuthorSchemaProxy.php';
use Maghead\Schema\SchemaLoader;
use Maghead\Result;
use Maghead\Runtime\BaseModel;
use Maghead\Inflator;
use SQLBuilder\Bind;
use SQLBuilder\ArgumentArray;
use PDO;
View php-orm-benchmarks
|-------------------------------------------------------------------------------------------------------|
| Library | Insert | findPk | complex| hydrate| with | memory usage | time |
| --------------------------------:| ------:| ------:| ------:| ------:| ------:| ------------:| ------:|
| PDO | 72 | 12 | 29 | 69 | 220 | 1,689,176 | 0.41 |
| Maghead | 395 | 9 | 176 | 205 | 365 | 10,485,760 | 1.16 |
| | | | | | | | |
| LessQL | 366 | 70 | 377 | 364 | 363 | 10,078,872 | 1.55 |
| | | | | | | | |
| YiiM | 714 | 86 | 436 | 292 | 614 | 8,388,608 | 2.16 |
| YiiMWithCache | 693 | 83 | 435 | 303
View AuthorBaseRepo.php
<?php
namespace AuthorBooks\Model;
require_once __DIR__ . '/AuthorSchemaProxy.php';
use Maghead\Schema\SchemaLoader;
use Maghead\Result;
use Maghead\BaseModel;
use Maghead\Inflator;
use SQLBuilder\Bind;
use SQLBuilder\ArgumentArray;
use PDO;
View sharding.md

Defining shards

sharding:
  mappings:
    M_store_id:
      tables: ["orders"]
      key: "store_id"
      hash:
        target1: order_shard_1
View BookBase.php
<?php
namespace AuthorBooks\Model;
use LazyRecord\Schema\SchemaLoader;
use LazyRecord\Result;
use LazyRecord\Inflator;
use SQLBuilder\Bind;
use SQLBuilder\ArgumentArray;
use PDO;
use SQLBuilder\Universal\Query\InsertQuery;
use TestApp\ModelTrait\EBookTrait;
View typeloy.json
{
"sites":{
"staging": {
"servers": [{
"host": "",
"username": "",
"password": ""
}],
"env": {
"MAIL_URL":"smtp://support",