2017 © Pedro Peláez
 

library potato-orm

image

ibonly/potato-orm

  • Sunday, May 20, 2018
  • by andela-iadeniyi
  • Repository
  • 1 Watchers
  • 2 Stars
  • 186 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

ƒ# Potato-ORM, (*1)

Build Status License Quality Score Scruitinizer Code Code Climate Test Coverage, (*2)

Potato-ORM is a package that manages the CRUD operation of database. Potato-ORM currently supports MYSQL, POSTGRES and SQLITE Database., (*3)

Installation

PHP 5.5+ and Composer are required., (*4)

Via Composer, (*5)

$ composer require ibonly/potato-orm
$ composer install

Usage

App Namespace

    namespace Ibonly\PotatoORM

Create a Class that correspond to the singular form of the table name in the database. i.e., (*6)

    namespace Ibonly\PotatoORM;

    class User extends Model
    {
        protected $table = 'tableName';

        protected fillables = ['name', 'email'];
    }

The table name can also be defined in the model if the user wants it to be specified., (*7)

The fields that is to be output can also be specified as protected $fillables = []., (*8)

The Model class contains getAll(), where([$field => $value]), find($value), save(), update() and detroy($id) methods., (*9)

getAll()

    use Ibonly\PotatoORM\User;

    $sugar = new User();

    return $sugar->getAll()->all();
Return type = JSON

where($field, $value)

    use Ibonly\PotatoORM\User;

    $sugar = new User();

    return $sugar->where([$field => $value])->first()->username;

Passing conditions to where, (*10)


return $sugar->where([$field => $value, $field2 => $value2], 'AND')->first()->username;
Return type = String

Update($value):

    use Ibonly\PotatoORM\User;
    $update = new User();

    $update->password = "password";
    echo $insert->update(1)

To return custom message, wrap the `save()` method in an `if statement`

Return type = Boolean

save()

    use Ibonly\PotatoORM\User;

    $insert = new User();
    $insert->id = NULL;
    $insert->username = "username";
    $insert->email = "example@example.com";
    $insert->password = "password";
    echo $insert->save();
To return custom message, wrap the `save()` method in an `if statement`

Return type = Boolean

file($fileName)->uploadFile()

This method is used to upload file, it can only be used along side save() and update($id), (*11)

    use Ibonly\PotatoORM\User;

    $insert = new User();
    $insert->id = NULL;
    $insert->username = "username";
    $insert->email = "example@example.com";
    $insert->avatar = $this->content->file($_FILES['image'])->uploadFile($uploadDirectory);
    $insert->password = "password";
    echo $insert->save();

detroy($value)

    use Ibonly\PotatoORM\User;

    $insert = User::destroy(2);
    die($insert);
Return type = Boolean

Create Database Table

Its is also possible to create Database Table with the Schema class. The table name will be specified in the createTable($name) method., (*12)

    use Ibonly\PotatoORM\Schema;

    $user = new Schema;
    $user->field('increments', 'id');
    $user->field('strings', 'username');
    $user->field('strings', 'name', 50);
    $user->field('integer', 'age');
    $user->field('primaryKey', 'id');

    echo $table->createTable('players');
Return type = Boolean

Database Constraint

Foreign Key, (*13)

    $user->field('foreignKey', 'id', 'users-id');

The reference table (users) and field (id) will be written as (users-id), (*14)

Unique Key, (*15)

    $user->field('unique', 'email')

Testing

$ vendor/bin/phpunit test

Contributing

To contribute and extend the scope of this package, Please check out CONTRIBUTING file for detailed contribution guidelines., (*16)

Credits

Potato-ORM is created and maintained by Ibraheem ADENIYI., (*17)

The Versions

20/05 2018

dev-andela-iadeniyi-patch-1

dev-andela-iadeniyi-patch-1

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

03/05 2016

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

03/05 2016

1.1

1.1.0.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

03/05 2016

1.0.0.x-dev

1.0.0.9999999-dev

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

01/05 2016

dev-Test

dev-Test

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

14/04 2016

v1.0.5.1

1.0.5.1

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

13/04 2016

v1.0.5

1.0.5.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

23/03 2016

v1.0.4

1.0.4.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

07/03 2016

1.0.3

1.0.3.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

07/03 2016

1.0.2

1.0.2.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

06/03 2016

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem

05/03 2016

v1.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires

by Adeniyi Ibraheem