kola / potato-orm
This is an ORM package that manages the persistence of database CRUD operations.
Requires
- php: >=5.5
- vlucas/phpdotenv: ^2.0
Requires (Dev)
- mockery/mockery: >=0.7.2
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2020-01-10 15:20:53 UTC
README
This is an ORM package that manages the persistence of simple database CRUD operations.
Installation
PHP 5.5+ and Composer are required.
Via Composer
$ composer require kola/potato-orm
$ composer install
Usage
Create a class with the name of the corresponding table in the database. Extend the class to the base class Model
under the namespace Kola\PotatoOrm
.
For instance, a class for dogs
or Dogs
or dog
or Dog
table should look like this:
namespace Kola\PotatoOrm; class Dog extends Model { }
- Create and save a record to database
$dog = new Dog(); $dog->name = "Rex"; $dog->breed= "Alsatian"; $dog->origin = "Germany"; $dog->save();
- Find and update a record in database
$dog = Dog::find(4); $dog->name = "Bruno"; $dog->save();
OR
$dog = Dog::where('name', 'Rex'); $dog->breed = "Rottweiler"; $dog->save();
- Delete a record
$dog = Dog::destroy(2);
Feel free to name the class as the singular of the name of the database table. For instance, User
class for users
table.
Note: Plurals of irregular nouns are not supported
For instance, a class Fish
should map to a table fish
or fishs
, not fishes
. And a class Child
should map to a table child
or childs
, not children
.
Supported database
Currently, only MYSQL and PostgreSQL are supported.
Work towards the support for other popular databases is in progress.
Change log
Please check out CHANGELOG file for information on what has changed recently.
Testing
$ vendor/bin/phpunit test
Contributing
Please check out CONTRIBUTING file for detailed contribution guidelines.
Credits
potato-orm is maintained by Kolawole ERINOSO
.
License
potato-orm is released under the MIT Licence. See the bundled LICENSE file for details.