All Projects → thewunder → corma

thewunder / corma

Licence: MIT License
Convention-based Object-Relational Mapper

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to corma

gene
Grace, fastest, flexibility, simple PHP extension framework!优雅、极速、灵活、简单的PHP扩展框架!
Stars: ✭ 30 (+7.14%)
Mutual labels:  orm
restjs
An “ORM” style library for consuming REST APIs on the frontend
Stars: ✭ 13 (-53.57%)
Mutual labels:  orm
storm
🌐⚡️LocalStorage manager library for JavaScript
Stars: ✭ 14 (-50%)
Mutual labels:  orm
heliosRX
⚡️ The fast way to build real-time apps with Vue and Firebase 🔥
Stars: ✭ 23 (-17.86%)
Mutual labels:  orm
gobatis
golang mybatis, 简单便捷
Stars: ✭ 46 (+64.29%)
Mutual labels:  orm
sequelize-adapter
Sequelize adapter for Casbin
Stars: ✭ 51 (+82.14%)
Mutual labels:  orm
java-bible
🍌 我的技术摘要
Stars: ✭ 2,950 (+10435.71%)
Mutual labels:  orm
monalisa-orm
Very Simple ORM
Stars: ✭ 70 (+150%)
Mutual labels:  orm
gorm-hibernate5
GORM for Hibernate 5
Stars: ✭ 51 (+82.14%)
Mutual labels:  orm
MeowVapor
Meow plugin for API generation
Stars: ✭ 12 (-57.14%)
Mutual labels:  orm
feathers-objection
Feathers database adapter for Objection.js, an ORM based on KnexJS SQL query builder for Postgres, Redshift, MSSQL, MySQL, MariaDB, SQLite3, and Oracle. Forked from feathers-knex.
Stars: ✭ 89 (+217.86%)
Mutual labels:  orm
MyDAL
The fastest and best ORM lite on C# for MySQL ! -- 友好, 轻量, 极致性能, 无任何第三方依赖, 持续演进~~
Stars: ✭ 32 (+14.29%)
Mutual labels:  orm
eloquent-mongodb-repository
Eloquent MongoDB Repository Implementation
Stars: ✭ 18 (-35.71%)
Mutual labels:  orm
pyhikvision
hikvision-sdk for Python3 in action
Stars: ✭ 141 (+403.57%)
Mutual labels:  orm
fsharp-dapper
The wrapper above the 'Dapper' library allows you to write more familiar code in the F # language. It also contains a functional for more simple work with temporary tables
Stars: ✭ 72 (+157.14%)
Mutual labels:  orm
pinipig
🚀 Performant webservice framework
Stars: ✭ 25 (-10.71%)
Mutual labels:  orm
ormdb
ORM tool for .Net / .Net.Core
Stars: ✭ 14 (-50%)
Mutual labels:  orm
graphql-tutorial
Tutorial for GraphQL
Stars: ✭ 24 (-14.29%)
Mutual labels:  orm
Sworm
CoreData based Swift ORM
Stars: ✭ 70 (+150%)
Mutual labels:  orm
doctrine-json-odm
JSON Object-Document Mapping bundle for Symfony and Doctrine
Stars: ✭ 15 (-46.43%)
Mutual labels:  orm

Corma

Latest Version on Packagist Software License Build Status Coverage Status SensioLabsInsight

Corma is a high-performance, convention-based ORM based on Doctrine DBAL.

Corma is great because:

  • No complex and difficult to verify annotations or configuration files
  • Promotes consistent code organization
  • Loads and saves one-to-one, one-to-many, and many-to-many relationships with a method call
  • Can save multiple objects in a single query (using an upsert)
  • Makes it easy to cache and avoid database queries
  • Supports soft deletes
  • Makes it easy to handle transactions in a Unit of Work
  • Highly customizable

Corma doesn't:

  • Autoload or lazy load relationships by default
  • Do migrations or code generation

Works in MySql and PostgreSQL.

Install via Composer

Via the command line:

composer.phar require thewunder/corma ~3.0

Or add the following to the require section your composer.json:

"thewunder/corma": "~3.0"

For PHP version > 5.5 < 7.1 use Corma version ~2.0

Basic Usage

Create a DataObject

namespace YourNamespace\Dataobjects;

class YourDataObject {
    protected $id;

    //If the property name == column name on the table your_data_objects it will be saved
    protected $myColumn;

    //Getters and setters..
}

And a Repository (optional)

namespace YourNamespace\Dataobjects\Repository;

class YourDataObjectRepository extends ObjectRepository {
    //Override default behavior and add custom methods...
}

Create the orm and use it

$db = DriverManager::getConnection(...); //see Doctrine DBAL docs
$orm = ObjectMapper::withDefaults($db);

$object = $orm->create(YourDataObject::class);
//Call setters...
$orm->save($object);
//Call more setters...
$orm->save($object);

//Call more setters on $object...
$objects = [$object];
$newObject = $orm->create(YourDataObject::class);
//call setters on $newObject..
$objects[] = $newObject;

$orm->saveAll($objects);

//find existing object by id
$existingObject = $orm->find(YourDataObject::class, 5);

//find existing objects with myColumn >= 42 AND otherColumn = 1
$existingObjects = $orm->findBy(YourDataObject::class, ['myColumn >='=>42, 'otherColumn'=>1], ['sortColumn'=>'ASC']);

//load relationships
$orm->loadOne($existingObjects, OtherObject::class, 'otherObjectId');
$orm->loadMany($existingObjects, AnotherObject::class, 'yourObjectId');
$orm->loadManyToMany($existingObjects, DifferentObject::class, 'link_table');

//delete those
$orm->deleteAll($existingObjects);

Documentation

See the wiki for full documentation.

Contributing

Please see CONTRIBUTING for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].