wilson/potato-orm

There is no license information available for the latest version (dev-master) of this package.

A simple PHP agnostic ORM

dev-master 2016-01-04 09:08 UTC

This package is not auto-updated.

Last update: 2024-10-30 18:24:11 UTC


README

Build Status

A simple ORM to insert, read, update, and delete data from a database written in PHP.

Install

Via Composer

$ composer require Wilson/potato-orm

Usage

  • 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);

Testing

If the folder containing your test classes is "tests"

$ phpunit tests

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email wilson.omokoro@andela.com instead of using the issue tracker.

Credits

Potato-orm is maintained by Wilson Omokoro.

License

The MIT License (MIT). Please see License File for more information.