andela-aonyango/potato-orm
Composer 安装命令:
composer require andela-aonyango/potato-orm
包简介
A lightweight ORM built using PHP and PDO.
README 文档
README
potato-orm
A light-weight ORM which allows you to insert records into a database, retrieve them, update them, and delete them.
Install
Via Composer
$ composer require andela-aonyango/potato-orm
In the package directory, run
$ composer install
Usage
Edit the example .env provided in the root of this package with the database settings you will use (make sure you .gitignore YOUR .env file). The one given uses MYSQL settings. PDO supports many database drivers so you can get familiar with what are valid/invalid inputs for the DSN and so on.
Sample Table
create table Person ( id int unsigned auto_increment primary key, first_name varchar(30) not null, last_name varchar(30) not null, age int(2), gender varchar(7) );
Sample Usage
<?php // Example usage of this ORM require "vendor/autoload.php"; use PotatoORM\Models\Person; $person = new Person(); $person->first_name = "yua"; $person->last_name = "madha"; $person->age = 73; // the add() method inserts an object and returns the last inserted id $id = $person->add(); // retrieve the just-added person $test = $person->find($id); print_r($test); $test->gender = "female"; $test->update(); // is the update successful print_r($test->find($id)); // delete the person from the database $test->remove(); // retrieve all people print_r($person->findAll()); ?>
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email andrew.onyango@andela.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-19