A simple ORM to insert, read, update, and delete data from a database written in PHP.
Via Composer
$ composer require Wilson/potato-orm
- Simply extend the base class. The base class is an abstract class called "Base". So for example if you have a users table in the database and you wish to perform create, read, update, and delete (CRUD) operations on the table, create a corresponding class like this
use Wilson\Source\Base;
class User extends Base
{
}
- Insert a record into the table
$person = new User();
$person->name = "Wilson Omokoro";
$person->email = "wilson.omokoro@andela.com";
$person->password = "12345";
$person->save();
- Find a particular record in the table
$user = User::find(3);
echo $user->result;
- Read all records from the table
$users = User::getAll();
print_r($users);
- Update a record in the table. For example update the password of the fifth record in the users table:
$user = User::find(5);
$user->password = "lkHJu9Z";
$user->save();
- Delete a record from the table. For example delete the third record in the users table:
$user = User::destroy(3);
If the folder containing your test classes is "tests"
$ phpunit tests
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email wilson.omokoro@andela.com instead of using the issue tracker.
Potato-orm is maintained by Wilson Omokoro.
The MIT License (MIT). Please see License File for more information.