SocialCompare
Link
DoctrineAgile DataEloquentYii ORMCake ORMFuel ORMRed Bean PHPTingSpiral ORM..
Sito webdoctrine-project.orggit.io/adyiiframework.comredbeanphp.comccmbg.com/...spiral-framework.com/...
DescrizioneData 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
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 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
Mi piace
0
4
0
1
1
0
0
0
0
0