Yii ORM

Products
2016-10-24 17:09:26
PHP Data Access Libraries (ORM, ActiveRecord, Persistence)
Yii ORM
Websitehttp://www.yiiframework.com/
Github / Bitbucket / Sourceforgehttps://github.com/yiisoft/yii2
LicenseBSD-3
Latest version2.0.10
How schema is defined?Active record magic properties.
Code generationYes Web and console generator https://github.com/yiisoft/yii2-gii
Can be used in Any Framework- Planned in 2.1.x
Automated CacheYes
Anti-patterns (purposely included)
Audience
Dependencies
Simplicity5.0 1 rating
Enterprise Compliance4.0 1 rating
Minimum PHP Version5.4
Basic Features
PDO SupportYes
NoSQL Integrate TransparentlyYes Avialable cross sql and nosql datababase relations
How to invoke db-vendor-specific extensions?Yes SQL - Query Builder.
Array as a persistenceYes https://github.com/yii2tech/filedb
RestAPI as a persistence- To extend BaseActiveRecord
JSON string as a persistence- To extend BaseActiveRecord
Same model, multiple persistences- (no docs)
Persistence Mapping (must support C,R,U,D)
Table Name MappingYes Using static method of active record. http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#declaring-ar-classes
Field Name MappingYes
Map Entity to SubQuery- table = new Expression(..)
Map property to expression- (couldn't find docs)
Map native types (DateTime)Yes Active record behaviors
User-defined types (e.g. "23 USD")Yes Active record behaviors
Map field of related Entity ('currency' = currency_id->Model Currency.name)Yes $model->currency->name
Map field to sub-query on related entity (Client.balance = Client->orders->sum(total))- (couldn't find docs)
Entity to join multiple tables (adding new record populates both tables)No No native support.
NoSQL (must be transparent to domain logic)
MongoDB supportYes https://github.com/yiisoft/yii2-mongodb
Neo4jNo
MemCache
Criteria, Scope, Conditions (Model will refuse to work with records that does not match criteria)
Support model-level criteriaNo
Soft-deleteYes Events and behaviors
Domain Model CriteriaNo Only for specific query: User::find()->byEmail('...')->active()->one()
Expression-based conditionNo Only for query: User::find()->andWhere('...')->all()
Criteria Compliance (new record must match condition)No
Dynamic criteriaNo Only Querying: User::find()->where(['a' => '1', 'b' => true])->all();
Query Building (Convert Model into Query object for further SQL tweaking)
Convert Model into Query ObjectYes \yii\db\ActiveRecord::find()
Raw expressionYes new \yii\db\Expression('...')
Nested/Composite Queries/ExpressionsYes Expression can be in any part of query
Reference domain-model field in queryNo Field is class property.
field, where, order, limitYes \yii\db\ActiveQuery
options, rollup, partition
UPDATE, DELETE, INSERT query buildingYes
REPLACE, TRUNCATE- Throught raw sql in \yii\db\Command
SHOW, DESCRIBE, CALL- Throught raw sql in \yii\db\Command
ALTER, CREATE query buildingYes
User-defined query templateYes (please link doc)
OR deep nested conditionsYes
Use Domain logic in multi-record updateNo
Data Fetching (different ways to retrieve data from database)
Get All Data (2x array)Yes \yii\db\Query::all()
Associative Array (id=>value)
Single rowYes \yii\db\Query::one()
Single ValueYes \yii\db\Query::scalar()
Single ColumnYes \yii\db\Query::column()
IteratorYes
Bypass persistence mapping
Loading and Saving individual records
Load by IDYes User::findOne(1)
Load by other fieldYes User::findOne(['id' => 1])
Load if expressionYes User::findOne('...')
Load respects Scope (model-level condition)- User::find()->where(...)->andWhere(...)->one()
Specify fields to loadYes User::find()->select([])->one()
Save only sends dirty fieldsYes
Guarded / Fillable properties
Object Hierarchy Model
Admin extends User (is_admin=1)No Can be done as wrapper: User::findAdmin(..) or custom CDbCriteria
Model that represent Orders of single User.No
Extend model, add Join (Disjoined SubTypes)No
Extend model change table
Relations/References (One model can relate to another model. NOT A TABLE JOIN)
Model can define relation to other ModelYes Relations
One-to-ManyYes
One-to-many traversal strategyUses classical eager/lazy loading approach. with() can help pre-fetch the data for related entities.
Lazy/Eager-loadingYes
One-to-OneYes
Many-to-ManyYes relations() method of an entity can define.
Deep Many-to-Many traversal.- only with "to-one" references: $book->author->address->street; Executes multiple queries.
Cross-Persistence traversal- No docs.
Multi-persistence Mapping (some data from SQL, others MongoDB)
Multi-persistence join
UNION existing models
Multi-persistence UNION
Multi-persistence value linking (current_sensor_value)
Behaviours / Hooks
Before/After operationYes
Hooks for C,R,U,D operationsYes
Persistence-specific hooks (to modify Query)- (no docs)
User-defined hooksYes
Auditing
Extension
Mapping strategy
How to set-up
Store old/new field valuesYes
Date of creation, modificationYes \yii\behaviors\TimestampBehavior
User/IP creation, modificationYes \yii\behaviors\BlameableBehavior
Store incremental revisions
Revert action (undo)No
Custom eventsYes
Custom fields, tableYes
Store in CSVNo
Access to record-specific history- Through a custom query.
Access Control
Implementation Strategy
Single-system global access scopeNo
Meta-information (allows exploration by UI widgets)
Implementation StrategyWidgets must specify data types manually, while dataProvider is used for fetching the data stream.
UI Widget can fetch list of Model Fields- \yii\grid\GridView, \yii\widgets\ListView
UI Widget can get Field type, default value, caption, hint- (no docs)
field storing reference to another Model can map into DropDownNo
Like 0
  • 2016-10-18 22:11:55
    2016-10-24 17:09:26
  • Products
    English
  • Public
    Public
  • Creative Commons License CC-BY-SA 3.0 / GNU FDL

Build comparison tables or lists about everything !

It's free and fast to publish data into original tables

Create a table