feat: initial commit of camelia/orm
Attribute-mapped Active Record ORM for MariaDB/MySQL over PDO. - Attribute-driven metadata: TableName, PrimaryKey, AutoIncrement, Column, Guarded, Ignore, Required, Enum, Nullable, Length, Precision, Unique, UniqueGroup, Index, MaxLength. - Relationship mapping: BelongsTo, HasOne, HasMany, BelongsToMany with batched eager loading and a 3-level depth limit. - Orm entry point with fromArray, fromPdo, fromEnv and nested transactions. - Immutable Query with Cond operators and GroupCond grouping. - Repository read and write API, pagination, and typed exception hierarchy. - Declares PHP >=8.3; Mago and PHPStan pin the parser to 8.3. - MIT license.
This commit is contained in:
commit
66e93e3070
97 files changed
+12188
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Camelia\Orm\Tests\Fixture\Invalid;
|
||||
|
||||
use Camelia\Orm\Attribute\Column;
|
||||
use Camelia\Orm\Attribute\PrimaryKey;
|
||||
use Camelia\Orm\Attribute\TableName;
|
||||
use Camelia\Orm\Model;
|
||||
|
||||
#[TableName('columna_duplicada')]
|
||||
final class ColumnaDuplicada extends Model
|
||||
{
|
||||
#[PrimaryKey]
|
||||
public ?int $codigo = null;
|
||||
|
||||
public string $nombre = '';
|
||||
|
||||
#[Column('nombre')]
|
||||
public string $nombreAlternativo = '';
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Camelia\Orm\Tests\Fixture\Invalid;
|
||||
|
||||
use Camelia\Orm\Attribute\PrimaryKey;
|
||||
use Camelia\Orm\Attribute\TableName;
|
||||
use Camelia\Orm\Model;
|
||||
|
||||
#[TableName('dos_pk')]
|
||||
final class DosPrimaryKeys extends Model
|
||||
{
|
||||
#[PrimaryKey]
|
||||
public ?int $codigo = null;
|
||||
|
||||
#[PrimaryKey]
|
||||
public ?int $otro = null;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Camelia\Orm\Tests\Fixture\Invalid;
|
||||
|
||||
use Camelia\Orm\Attribute\BelongsTo;
|
||||
use Camelia\Orm\Attribute\PrimaryKey;
|
||||
use Camelia\Orm\Attribute\TableName;
|
||||
use Camelia\Orm\Model;
|
||||
use Camelia\Orm\Tests\Fixture\Usuario;
|
||||
|
||||
#[TableName('relacion_no_nulable')]
|
||||
final class RelacionNoNulable extends Model
|
||||
{
|
||||
#[PrimaryKey]
|
||||
public ?int $codigo = null;
|
||||
|
||||
#[BelongsTo(Usuario::class, foreignKey: 'codigo')]
|
||||
public Usuario $usuario;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Camelia\Orm\Tests\Fixture\Invalid;
|
||||
|
||||
use Camelia\Orm\Attribute\TableName;
|
||||
use Camelia\Orm\Model;
|
||||
|
||||
#[TableName('sin_pk')]
|
||||
final class SinPrimaryKey extends Model
|
||||
{
|
||||
public string $nombre = '';
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Camelia\Orm\Tests\Fixture\Invalid;
|
||||
|
||||
use Camelia\Orm\Attribute\PrimaryKey;
|
||||
use Camelia\Orm\Model;
|
||||
|
||||
final class SinTableName extends Model
|
||||
{
|
||||
#[PrimaryKey]
|
||||
public ?int $codigo = null;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Camelia\Orm\Tests\Fixture\Invalid;
|
||||
|
||||
use Camelia\Orm\Attribute\PrimaryKey;
|
||||
use Camelia\Orm\Attribute\TableName;
|
||||
use Camelia\Orm\Model;
|
||||
|
||||
#[TableName('sin_tipo')]
|
||||
final class SinTipo extends Model
|
||||
{
|
||||
#[PrimaryKey]
|
||||
public ?int $codigo = null;
|
||||
|
||||
public $nombre;
|
||||
}
|
||||
Reference in new issue
Block a user