Compare Sizes
Register
English Français Español

PHP Data Access Libraries (ORM, ActiveRecord, Persistence)

2
For description on the comparison criteria, please read full article here: medium.com/...
Link
DoctrineAgile DataEloquentYii ORMCake ORMFuel ORMRed Bean PHPTingSpiral ORM..
Webseitedoctrine-project.orggit.io/adyiiframework.comredbeanphp.comccmbg.com/...spiral-framework.com/...
BeschreibungData 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 generationJa schema-toolJa https://github.com/atk4/schemaJa Web and console generator https://github.com/yiisoft/yii2-gii
Can be used in Any FrameworkJa composer / packagistJa Through composer/packagistJa Through Capsule- Planned in 2.1.xJaJa composer / packagist
Automated CacheJa Frameworks focuses on optimizing queries rather then caching. Still possible with cross-persistence saving.JaJa
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
no rating
5.0/5 2 ratings
no rating
5.0/5 2 ratings
5.0/5 1 rating
no rating
no rating
5.0/5 1 rating
no rating
no rating
Enterprise Compliance
5.0/5 1 rating
5.0/5 2 ratings
3.0/5 1 rating
4.5/5 2 ratings
5.0/5 1 rating
no rating
no rating
5.0/5 1 rating
no rating
no rating
Minimum PHP Version5.45.65.45.5
Basic Features
PDO SupportJa YesJa YesJaJa- But made a custom driver to support it is easyJa https://spiral-framework.com/guide/database-databases
Transparent support for NoSQL- Through 3rd party drivers.Nein Eloquent is built on Query Builder. Perhaps moloquent? Also - Through Caching backend, but not as ORM native persistence.Ja Avialable cross sql and nosql datababase relations (https://github.com/yiisoft/yii2-mongodb)Nein Build around plain queries.NeinNein No, through ODM (https://spiral-framework.com/guide/odm-databases)
How to invoke db-vendor-specific extensions?Ja DBALJa For SQL - save/load/delete operations are expressed in DSQL Queries that can be manipulated: http://git.io/dsqlJa Through Query Builder / RAW queries.Ja SQL - Query Builder.- Can add SQL code chunks.Ja Ting use native query, you can use everyting of your SGBDJa Query models: https://spiral-framework.com/guide/orm-query
Array as a persistenceJa CRUD operations supportedJa https://github.com/yii2tech/filedbNeinNein
RestAPI as a persistence- Through 3rd party extension.- To extend BaseActiveRecordNeinNein
JSON string as a persistenceJa Supported with few extra lines of code.- To extend BaseActiveRecordNeinNein
Same model, multiple persistencesJa Same class. Different object.- (no docs)
Basic Single-record operations (C,R,U,D)
Table Name MappingJa YesJa YesJa Same as model class name by defaultJa Using static method of active record. http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#declaring-ar-classesNein mapping no longer supported.Ja Yes
Field Name MappingJa Yes, (Annotations in PHP)Ja Yes (Field::actual property)- Through accessors/3rd party extensionJaNein mapping no longer supported.Ja Yes
Map Entity to SubQueryNein Must be physical tableJa Yes. Extension exist for UNION-models. https://github.com/atk4/reportNein Must be physical table.- table = new Expression(..)NeinNein This concept is no-sense for Ting
Map property to expressionNein Must be physical fieldJa $model->addExpression()Nein Must be physical table- (couldn't find docs)NeinNein This concept is no-sense for Ting
Map native types (DateTime)Ja $field->type = 'date'Ja Accessors and MutatorsJa Active record behaviorsJaJa Yes- No support for DateTime. https://spiral-framework.com/guide/orm-accessors
User-defined types (e.g. "23 USD")Ja Type classJa Yes. Independent from Model. by extending Field class.Ja Accessors and MutatorsJa Active record behaviorsJa Yes, with custom serializer
Map field of related Entity ('currency' = currency_id->Model Currency.name)- Specific record onlyJa Transparently maps into sub-select.- Relationship, but only single record.Ja $model->currency->nameNeinJa Yes
Map field to sub-query on related entity (Client.balance = Client->orders->sum(total))NeinJa Yes. hasMany()->addField(..aggregate)Nein- (couldn't find docs)Nein- This concept is no-sense for Ting
Entity to join multiple tables (adding new record populates both tables)Ja AssociationsJa $model->join('other_table')NeinNein No native support.NeinJa Yes
Criteria, Scope, Conditions (Model will refuse to work with records that does not match criteria)
Support model-level criteriaJa Yes. Applied on loading / saving / update.- Global Scope (querying only)NeinNein
Soft-deleteJa ExtensionJa Through criteria. Example given in the docs.Ja Trait and ScopeJa Events and behaviorsNein
Domain Model CriteriaJa $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.Nein Only for specific query: User::find()->byEmail('...')->active()->one()Nein
Expression-based conditionJa $m->addCondition($m->expr('..'));Ja through Query BuilderNein Only for query: User::find()->andWhere('...')->all()Nein
Criteria Compliance (new record must match condition)Ja Transaction rollback and exception. Automated-rloading.NeinNein
Dynamic criteriaJa $user->addCondition('is_expired', false)Nein Only Querying: User::find()->where(['a' => '1', 'b' => true])->all();Nein
Query Building (Convert Model into Query object for further SQL tweaking)
Convert Model into Query ObjectJa $q = $model->action('select');Ja Model is a Query object. See: Model::where()Ja \yii\db\ActiveRecord::find()NeinJa RecordSelector
Raw expressionJa new Expression('any sql')Ja DB::raw()Ja new \yii\db\Expression('...')JaJa
Nested/Composite Queries/ExpressionsJa Expression can be in any part of queryNeinJa Expression can be in any part of queryNein
Reference domain-model field in queryJa through Expressionable interfaceNein No fields. Only properties.Nein Field is class property.NeinNein
field, where, order, limitJa Expressions and Parametric valuesJaJa \yii\db\ActiveQueryNeinJa
options, rollup, partition- Through custom templates, or expressions.- not sure.
UPDATE, DELETE, INSERT query buildingJaJaNeinJa
REPLACE, TRUNCATEJa- 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 buildingJa Addon: http://github.com/atk4/schemaJaNein
User-defined query templateJa Templates for all queriesJa (please link doc)Nein
full support for OR conditionsJa Through Object Composition and Expressions- Partial-Nein only raw query
Use Domain logic in multi-record update- Supported, but must map fields/values manually.NeinNeinNein
Data Fetching (different ways to retrieve data from database)
Get All Data (2x array)JaJaJa \yii\db\Query::all()Ja exportAll()Ja
Associative Array (id=>value)Nein PlannedJa lists()
Select only required fieldsJa
Typecasting (e.g. DateTime)JaJa
Import (multiple records)JaJa
Respect domain model mapping (and criteria)Ja
Single rowJa loadAnyJaJa \yii\db\Query::one()Ja
Single ValueJa Through actionJaJa \yii\db\Query::scalar()Ja
Single Column- may need to map resulting arrayJaJa \yii\db\Query::column()JaJa
IteratorJaJaJa
Bypass persistence mappingJa action('select')->getAll()Ja ?? (e..g prevent date from being transformed into Carbon)
Loading and Saving individual records
Load by IDJa load(id)Ja User::findOne(1)JaJa get(id)Ja findByPK
Load by other fieldJa loadBy('field', $value)Ja User::findOne(['id' => 1])NeinJa getBy(['propertyName' => 'value']);
Read-only ModelsJa YesNein
Model without primary keyJa Yes, but only in Read-only ModeNeinJa
Specify fields to loadJa onlyFields()Nein Fields load with SELECT *Ja User::find()->select([])->one()NeinJa
Save only sends dirty fieldsJaJaJa- (there is Dirty support, so I assuming it is supported)JaJa
Guarded / Fillable propertiesJa Conditions and OnlyFields do same thing but more reliably.Ja Prevents "create($_GET)" from messing up important fields.
Object Hierarchy Model
Admin extends User, adds criteria (is_admin=1)Ja Yes, recommended pattern. "User" class adds condition.NeinNein Can be done as wrapper: User::findAdmin(..) or custom CDbCriteriaNein
Admin extends User, adds accessible fieldsJa Yes, recommended pattern.NeinNeinNein
Extend model, add Join (Disjoined SubTypes)Ja Yes. Unlimited number of joins.NeinNeinNein
Extend model change tableJa Yes. Used to tweak 3rd party models.Nein
Relations/References (One model can relate to another model. NOT A TABLE JOIN)
Model can define relation to other ModelJa References are implemented as ObjectsJa RelationsJa RelationsJa
One-to-ManyJa $user->hasMany('Orders', new Order());JaJa
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-loadingNein Anti-patternJaJaJa
One-to-OneJa $order->hasOne('user_id', new User());JaJa
Many-to-ManyJa $user->addCondition('vip', true)->ref('Orders');Ja relations() method of an entity can define.
Deep Many-to-Many traversal.NeinJa $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 traversalJa $user->hasMany('Log', new Log($mongodb));- No docs.Nein
Cross-persistence joins, aggregation, reporting
Multi-persistence joinNeinNeinNeinNein
UNION existing modelsNeinJa Yes, in add-on https://github.com/atk4/report/. Can join UNION result with more tables.NeinNein
Domain-model AggregationJa Group by multiple fields. Apply aggregation functions. Preserve types.Nein
Model to Model joinNein Planned.Nein
Multi-persistence UNIONNeinNeinNeinNein
Behaviours / Hooks
Before/After operationJaJa
Override standard C,R,U,D operationsJaJa
Persistence-specific hooks (to modify Query)Ja- (no docs)
User-defined hooksJaJa
Auditing
Global AuditingJa http://www.agiletoolkit.org/data/extensions/auditNein
Store old/new field valuesJa Yes in JSON and user-readable string.Ja
Revert action (undo) and replay (redo)JaNeinNein
Reactive actionsJa Each action will be automatically linked with sub-actions which may be invoked through Hooks.
Store log in any persistenceJaNein
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 eventsJaJa
Access to record-specific historyJa $item->ref('AuditLog');- Through a custom query.
Date of creation, modification- No but easy to add through hook.Ja \yii\behaviors\TimestampBehaviorJa TimestampTrait
User/IP creation, modification- Easy to add through a hook.Ja \yii\behaviors\BlameableBehavior
Store incremental revisions- Easy to add through a hookJa
Integration
Field meta-information providedType, caption, possible values, mapped field, join table spec, encryption, serialization, UI-specific settings, validation rules.
UI extensionsNeinJa CRUD, Form, Table, Grid, Entity-manager. (see https://github.com/atk4/ad)NeinNeinNein
API extensionsJa RestFULL API, automated CRUD operations + RPC https://github.com/atk4/api
Ich mag das
0
3
0
1
1
0
0
0
0
0
Embed
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