ibonly/potato-orm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ibonly/potato-orm

最新稳定版本:1.1

Composer 安装命令:

composer require ibonly/potato-orm

包简介

README 文档

README

ƒ# Potato-ORM

Build Status License Quality Score Scruitinizer Code Code Climate Test Coverage

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

Installation

PHP 5.5+ and Composer are required.

Via Composer

$ 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.

    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.

The fields that is to be output can also be specified as protected $fillables = [].

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

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

    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)

    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.

    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

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

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

Unique Key

    $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.

Credits

Potato-ORM is created and maintained by Ibraheem ADENIYI.

统计信息

  • 总下载量: 204
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-10-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固