Comparar tamaños
Registrarse
English Français

PHP Data Access Libraries (ORM, ActiveRecord, Persistence)

2
For description on the comparison criteria, please read full article here: medium.com/...
Enlace
DoctrineAgile DataEloquentYii ORMCake ORMFuel ORMRed Bean PHPTingSpiral ORM..
Sitio webdoctrine-project.orggit.io/adyiiframework.comredbeanphp.comccmbg.com/...spiral-framework.com/...
DescripciónData Access Framework for high-latency databases (Cloud SQL/NoSQL).RedBeanPHP is an easy to use ORM for PHP. It's a Zero Config ORM lib that 'automagically' builds your database schema.Simple: no magic inside : it’s basically SQL queriesORM engine with automatic database scaffolding, strict schemas, code discovery, modular database partitions and various relation loaders.
Github / Bitbucket / Sourceforgegithub.com/...git.io/adgithub.com/...github.com/...bitbucket.org/...github.com/...
LicenseMITMITBSD-3New BSD / GPLApache 2MIT
Latest version2.5.51.2.x2.0.104.3.23.4.21.0.8
How schema is defined?PHP, XML, YAMLin PHP. Method init() in Model class defines fields, relations, conditions, etc.Model class propertiesActive record magic properties.Automatically discovered on the fly.PHPPHP Const array. Column class.
Code generationSí schema-toolSí https://github.com/atk4/schemaSí Web and console generator https://github.com/yiisoft/yii2-gii
Can be used in Any FrameworkSí composer / packagistSí Through composer/packagistSí Through Capsule- Planned in 2.1.xSíSí composer / packagist
Automated CacheSí Frameworks focuses on optimizing queries rather then caching. Still possible with cross-persistence saving.SíSí
Anti-patterns (purposely included)Model close-coupled with Persistence and Field classes.Eloquent is a God Class; Global functions; DB Conection is global;
Audience
DependenciesMedium: ±5 packages.Minimal: 2 packages: DSQL Query Builder (git.io/...Minimal: 3, pimple, doctrine/cache, aura/sqlquery
Simplicity
sin puntuaciones
5.0/5 2 Calificaciones
sin puntuaciones
5.0/5 2 Calificaciones
5.0/5 1 Valoración
sin puntuaciones
sin puntuaciones
5.0/5 1 Valoración
sin puntuaciones
sin puntuaciones
Enterprise Compliance
5.0/5 1 Valoración
5.0/5 2 Calificaciones
3.0/5 1 Valoración
4.5/5 2 Calificaciones
5.0/5 1 Valoración
sin puntuaciones
sin puntuaciones
5.0/5 1 Valoración
sin puntuaciones
sin puntuaciones
Minimum PHP Version5.45.65.45.5
Basic Features
PDO SupportSí YesSí YesSíSí- But made a custom driver to support it is easySí https://spiral-framework.com/guide/database-databases
Transparent support for NoSQL- Through 3rd party drivers.No Eloquent is built on Query Builder. Perhaps moloquent? Also - Through Caching backend, but not as ORM native persistence.Sí Avialable cross sql and nosql datababase relations (https://github.com/yiisoft/yii2-mongodb)No Build around plain queries.NoNo No, through ODM (https://spiral-framework.com/guide/odm-databases)
How to invoke db-vendor-specific extensions?Sí DBALSí For SQL - save/load/delete operations are expressed in DSQL Queries that can be manipulated: http://git.io/dsqlSí Through Query Builder / RAW queries.Sí SQL - Query Builder.- Can add SQL code chunks.Sí Ting use native query, you can use everyting of your SGBDSí Query models: https://spiral-framework.com/guide/orm-query
Array as a persistenceSí CRUD operations supportedSí https://github.com/yii2tech/filedbNoNo
RestAPI as a persistence- Through 3rd party extension.- To extend BaseActiveRecordNoNo
JSON string as a persistenceSí Supported with few extra lines of code.- To extend BaseActiveRecordNoNo
Same model, multiple persistencesSí Same class. Different object.- (no docs)
Basic Single-record operations (C,R,U,D)
Table Name MappingSí YesSí YesSí Same as model class name by defaultSí Using static method of active record. http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#declaring-ar-classesNo mapping no longer supported.Sí Yes
Field Name MappingSí Yes, (Annotations in PHP)Sí Yes (Field::actual property)- Through accessors/3rd party extensionSíNo mapping no longer supported.Sí Yes
Map Entity to SubQueryNo Must be physical tableSí Yes. Extension exist for UNION-models. https://github.com/atk4/reportNo Must be physical table.- table = new Expression(..)NoNo This concept is no-sense for Ting
Map property to expressionNo Must be physical fieldSí $model->addExpression()No Must be physical table- (couldn't find docs)NoNo This concept is no-sense for Ting
Map native types (DateTime)Sí $field->type = 'date'Sí Accessors and MutatorsSí Active record behaviorsSíSí Yes- No support for DateTime. https://spiral-framework.com/guide/orm-accessors
User-defined types (e.g. "23 USD")Sí Type classSí Yes. Independent from Model. by extending Field class.Sí Accessors and MutatorsSí Active record behaviorsSí Yes, with custom serializer
Map field of related Entity ('currency' = currency_id->Model Currency.name)- Specific record onlySí Transparently maps into sub-select.- Relationship, but only single record.Sí $model->currency->nameNoSí Yes
Map field to sub-query on related entity (Client.balance = Client->orders->sum(total))NoSí Yes. hasMany()->addField(..aggregate)No- (couldn't find docs)No- This concept is no-sense for Ting
Entity to join multiple tables (adding new record populates both tables)Sí AssociationsSí $model->join('other_table')NoNo No native support.NoSí Yes
Criteria, Scope, Conditions (Model will refuse to work with records that does not match criteria)
Support model-level criteriaSí Yes. Applied on loading / saving / update.- Global Scope (querying only)NoNo
Soft-deleteSí ExtensionSí Through criteria. Example given in the docs.Sí Trait and ScopeSí Events and behaviorsNo
Domain Model CriteriaSí $m->addCondition('gender','M'); where 'gender' can be arbitrary expression, sub-select, field from association(join) or mapped no another physical field.- Scopes, but not in domain model.No Only for specific query: User::find()->byEmail('...')->active()->one()No
Expression-based conditionSí $m->addCondition($m->expr('..'));Sí through Query BuilderNo Only for query: User::find()->andWhere('...')->all()No
Criteria Compliance (new record must match condition)Sí Transaction rollback and exception. Automated-rloading.NoNo
Dynamic criteriaSí $user->addCondition('is_expired', false)No Only Querying: User::find()->where(['a' => '1', 'b' => true])->all();No
Query Building (Convert Model into Query object for further SQL tweaking)
Convert Model into Query ObjectSí $q = $model->action('select');Sí Model is a Query object. See: Model::where()Sí \yii\db\ActiveRecord::find()NoSí RecordSelector
Raw expressionSí new Expression('any sql')Sí DB::raw()Sí new \yii\db\Expression('...')SíSí
Nested/Composite Queries/ExpressionsSí Expression can be in any part of queryNoSí Expression can be in any part of queryNo
Reference domain-model field in querySí through Expressionable interfaceNo No fields. Only properties.No Field is class property.NoNo
field, where, order, limitSí Expressions and Parametric valuesSíSí \yii\db\ActiveQueryNoSí
options, rollup, partition- Through custom templates, or expressions.- not sure.
UPDATE, DELETE, INSERT query buildingSíSíNoSí
REPLACE, TRUNCATESí- Throught raw sql in \yii\db\Command- wipe(),
SHOW, DESCRIBE, CALL- Supported through Expressions or Custom query template- Throught raw sql in \yii\db\Command- Automatic schema alter / discovery.
ALTER, CREATE query buildingSí Addon: http://github.com/atk4/schemaSíNo
User-defined query templateSí Templates for all queriesSí (please link doc)No
full support for OR conditionsSí Through Object Composition and Expressions- Partial-No only raw query
Use Domain logic in multi-record update- Supported, but must map fields/values manually.NoNoNo
Data Fetching (different ways to retrieve data from database)
Get All Data (2x array)SíSíSí \yii\db\Query::all()Sí exportAll()Sí
Associative Array (id=>value)No PlannedSí lists()
Select only required fieldsSí
Typecasting (e.g. DateTime)SíSí
Import (multiple records)SíSí
Respect domain model mapping (and criteria)Sí
Single rowSí loadAnySíSí \yii\db\Query::one()Sí
Single ValueSí Through actionSíSí \yii\db\Query::scalar()Sí
Single Column- may need to map resulting arraySíSí \yii\db\Query::column()SíSí
IteratorSíSíSí
Bypass persistence mappingSí action('select')->getAll()Sí ?? (e..g prevent date from being transformed into Carbon)
Loading and Saving individual records
Load by IDSí load(id)Sí User::findOne(1)SíSí get(id)Sí findByPK
Load by other fieldSí loadBy('field', $value)Sí User::findOne(['id' => 1])NoSí getBy(['propertyName' => 'value']);
Read-only ModelsSí YesNo
Model without primary keySí Yes, but only in Read-only ModeNoSí
Specify fields to loadSí onlyFields()No Fields load with SELECT *Sí User::find()->select([])->one()NoSí
Save only sends dirty fieldsSíSíSí- (there is Dirty support, so I assuming it is supported)SíSí
Guarded / Fillable propertiesSí Conditions and OnlyFields do same thing but more reliably.Sí Prevents "create($_GET)" from messing up important fields.
Object Hierarchy Model
Admin extends User, adds criteria (is_admin=1)Sí Yes, recommended pattern. "User" class adds condition.NoNo Can be done as wrapper: User::findAdmin(..) or custom CDbCriteriaNo
Admin extends User, adds accessible fieldsSí Yes, recommended pattern.NoNoNo
Extend model, add Join (Disjoined SubTypes)Sí Yes. Unlimited number of joins.NoNoNo
Extend model change tableSí Yes. Used to tweak 3rd party models.No
Relations/References (One model can relate to another model. NOT A TABLE JOIN)
Model can define relation to other ModelSí References are implemented as ObjectsSí RelationsSí RelationsSí
One-to-ManySí $user->hasMany('Orders', new Order());SíSí
One-to-many traversal strategyReturns destination model instance with dynamically applied criteria (parent_id=123). No queries are executed. Inserting record into this model will ensure association with parent model.Returns array of objects that may either be pre-loaded with record data or only contain IDs (lazy-loaded).Uses classical eager/lazy loading approach. with() can help pre-fetch the data for related entities.pre-fetch and store objects in an array.
Lazy/Eager-loadingNo Anti-patternSíSíSí
One-to-OneSí $order->hasOne('user_id', new User());SíSí
Many-to-ManySí $user->addCondition('vip', true)->ref('Orders');Sí relations() method of an entity can define.
Deep Many-to-Many traversal.NoSí $user->ref('Orders')->ref('Payments')->action('count'); No intermediate queries.- only with "to-one" references: $book->author->address->street; Executes multiple queries.- only with to-one references. Executes multiple queries.
Cross-Persistence traversalSí $user->hasMany('Log', new Log($mongodb));- No docs.No
Cross-persistence joins, aggregation, reporting
Multi-persistence joinNoNoNoNo
UNION existing modelsNoSí Yes, in add-on https://github.com/atk4/report/. Can join UNION result with more tables.NoNo
Domain-model AggregationSí Group by multiple fields. Apply aggregation functions. Preserve types.No
Model to Model joinNo Planned.No
Multi-persistence UNIONNoNoNoNo
Behaviours / Hooks
Before/After operationSíSí
Override standard C,R,U,D operationsSíSí
Persistence-specific hooks (to modify Query)Sí- (no docs)
User-defined hooksSíSí
Auditing
Global AuditingSí http://www.agiletoolkit.org/data/extensions/auditNo
Store old/new field valuesSí Yes in JSON and user-readable string.Sí
Revert action (undo) and replay (redo)SíNoNo
Reactive actionsSí Each action will be automatically linked with sub-actions which may be invoked through Hooks.
Store log in any persistenceSíNo
Override, Add fields to audit logRecord dirty fields before persisting. Type-cast into JSON string and store in a single field of AuditLog Model. This model can be persisted anywhere, table, file, etc.
Custom eventsSíSí
Access to record-specific historySí $item->ref('AuditLog');- Through a custom query.
Date of creation, modification- No but easy to add through hook.Sí \yii\behaviors\TimestampBehaviorSí TimestampTrait
User/IP creation, modification- Easy to add through a hook.Sí \yii\behaviors\BlameableBehavior
Store incremental revisions- Easy to add through a hookSí
Integration
Field meta-information providedType, caption, possible values, mapped field, join table spec, encryption, serialization, UI-specific settings, validation rules.
UI extensionsNoSí CRUD, Form, Table, Grid, Entity-manager. (see https://github.com/atk4/ad)NoNoNo
API extensionsSí RestFULL API, automated CRUD operations + RPC https://github.com/atk4/api
Me gusta
0
4
0
1
1
0
0
0
0
0
Integrar
Compare Doctrine vs Agile Data vs Eloquent vs Yii ORM vs Cake ORM vs Fuel ORM vs x vs x
Products
English
Public
Public
2017-12-21 16:47:00
View changes
Manage backups

User reviews and comments