https://github.com/ihabunek/phormium
Phormium is a minimal ORM for PHP (which incidentally works with Informix)
https://github.com/ihabunek/phormium
Last synced: 5 months ago
JSON representation
Phormium is a minimal ORM for PHP (which incidentally works with Informix)
- Host: GitHub
- URL: https://github.com/ihabunek/phormium
- Owner: ihabunek
- License: other
- Archived: true
- Created: 2012-10-11T08:43:18.000Z (over 12 years ago)
- Default Branch: develop
- Last Pushed: 2022-05-24T09:06:46.000Z (almost 3 years ago)
- Last Synced: 2024-10-01T11:01:47.928Z (7 months ago)
- Language: PHP
- Size: 880 KB
- Stars: 55
- Watchers: 8
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
Phormium
========Phormium is a minimalist ORM for PHP.
Tested on Informix, MySQL, PosgreSQL and SQLite. Might work on other databases
with a PDO driver or may require some work.---
**This project is no longer maintained and the repository is archived. Thanks for all the fish.**
---
[](https://packagist.org/packages/phormium/phormium) [](https://packagist.org/packages/phormium/phormium) [](https://travis-ci.org/ihabunek/phormium) [](https://coveralls.io/r/ihabunek/phormium)
Features
--------* CRUD operations made simple
* batch update and delete
* filtering
* ordering
* limiting
* transactions
* custom queries
* eventsDocumentation
-------------[The documentation](http://phormium.readthedocs.org/en/latest/) is hosted by
ReadTheDocs.org.Showcase
--------After initial setup, Phormium is very easy to use. Here's a quick overview of
it's features:```php
// Create a new person record
$person = new Person();
$person->name = "Frank Zappa";
$person->birthday = "1940-12-21";
$person->save();// Get record by primary key
Person::get(10); // Throws exception if the model doesn't exist
Person::find(10); // Returns null if the model doesn't exist// Check record exists by primary key
Person::exists(10);// Also works for composite primary keys
Post::get('2013-01-01', 100);
Post::find('2013-01-01', 100);
Post::exists('2013-01-01', 100);// Primary keys can also be given as arrays
Post::get(['2013-01-01', 100]);
Post::find(['2013-01-01', 100]);
Post::exists(['2013-01-01', 100]);// Fetch, update, save
$person = Person::get(10);
$person->salary += 5000; // give the man a raise!
$person->save();// Fetch, delete
Person::get(37)->delete();// Intuitive filtering, ordering and limiting
$persons = Person::objects()
->filter('salary', '>', 10000)
->filter('birthday', 'between', ['2000-01-01', '2001-01-01'])
->orderBy('name', 'desc')
->limit(100)
->fetch();// Count records
$count = Person::objects()
->filter('salary', '>', 10000)
->count();// Check if any records matching criteria exist
$count = Person::objects()
->filter('salary', '>', 10000)
->exists();// Distinct values
$count = Person::objects()
->distinct('name', 'email');// Complex composite filters
$persons = Person::objects()->filter(
Filter::_or(
Filter::_and(
array('id', '>=', 10),
array('id', '<=', 20)
),
Filter::_and(
array('id', '>=', 50),
array('id', '<=', 60)
),
array('id', '>=', 100),
)
)->fetch();// Fetch a single record (otherwise throws an exeption)
$person = Person::objects()
->filter('email', '=', '[email protected]')
->single();// Batch update
Person::objects()
->filter('salary', '>', 10000)
->update(['salary' => 5000]);// Batch delete
Person::objects()
->filter('salary', '>', 10000)
->delete();// Aggregates
Person::objects()->filter('name', 'like', 'Ivan%')->avg('salary');
Person::objects()->filter('name', 'like', 'Marko%')->min('birthday');// Custom filters with argument binding
Person::objects()
->filter("my_func(salary) > ?", [100])
->fetch();
```See [documentation](http://phormium.readthedocs.org/en/latest/) for full
reference, also check out the `example` directory for more examples.Why?
----"Why another ORM?!?", I hear you cry.
There are two reasons:
* I work a lot on Informix on my day job and no other ORM I found supports it.
* Writing an ORM is a great experience. You should try it.Phormium is greatly inspired by other ORMs, in particular:
* [Django ORM](https://docs.djangoproject.com/en/dev/topics/db/)
* Laravel's [Eloquent ORM](http://laravel.com/docs/database/eloquent)
* [Paris](http://j4mie.github.io/idiormandparis/)Let me know what you think!
Ivan Habunek [@ihabunek](http://twitter.com/ihabunek)
Praise
------If you like it, buy me a beer (in Croatia, that's around €2 or $3).
[](http://flattr.com/thing/1204532/ihabunekphormium-on-GitHub)
License
-------
Licensed under the MIT license. `See LICENSE.md`.