taylor-hawkes/tays-orm
最新稳定版本:v1.0.2
Composer 安装命令:
composer require taylor-hawkes/tays-orm
包简介
Quick and easy ORM
README 文档
README
This is a super simple class for saving/editing record in a mysql database. It really helps for quickly/easily updating single records. #installation & usage
Install with composer:
composer require taylor-hawkes\easy-connect composer require taylor-hawkes\tays-orm
Generate a new model with the generator script:
cd vendor/taylor-hawkes/tays-orm
php generate_model.php --table="users" --host="database_ip" --user="db_user" --pass="db_pass" --database="db_name" --table="tablename"
You can hard code the database params in the generate_table script so you don't have to put them in as params everytime.
This script by default installs all new Models and Base Models three directories up (in a TModel folder) from the TaysORM installation directory. You can edit where the script installs your Models.
Usage Examples:
Create a new user:
$user=new \TModel\Users(); $user->first_name="taylor"; $user->last_name="hawkes"; $user->save();
Edit a user:
$user=new \TModel\Users(); $user->fetchRow("1");// 1 is the value of the tables primary key $user->last_name="Malone"; // I got married and was forced to take my wifes name $user->save();
You can also fetch a row like this:
$user=new \TModel\Users(); $user->fetchRowWhere("first_name = 'taylor' and lastname ='hawkes'"); $user->last_name="Malone"; $user->save();
Selecting Multiple Records:
$user=new \TModel\Users(); $all_users= $user->fetchAssoc("select * from users");
All Other Queries:
$user=new \TModel\Users(); $do_something_else=$user->query("update users set ...");
Requirements
EasyConnect - [https://github.com/TaylorHawkes/EasyConnect]
License
MIT
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-02