定制 vundi/potato-orm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vundi/potato-orm

Composer 安装命令:

composer require vundi/potato-orm

包简介

An ORM package that allows you to perform basic CRUD operations on any database

README 文档

README

Build Status Coverage Status Scrutinizer Code Quality Software License

POTATO ORM is a custom ORM that allows you to perform all CRUD operations on a table when working with any database

Install

Installation via Composer

$ composer require vundi/potato-orm

Usage

Configuration SQL databases

NOTE: Load you connection variables from the .env file in the root folder. If you do not have a .env file in your root folder or don't know about it, please read this phpdotenv project.

Provide Database host, database user, database password and the type in the .env file. Once you provide the right values a Database connection will be established.

// Load the `.env` variables for the project
// Check the `.env.example` file in the root of the project to see the environment variables needed.
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();

Once we have a connection, we create a model class which extends Model. Inside the model class set the entity table name

require 'vendor/autoload.php';

use Vundi\Potato\Model;
use Vundi\Potato\Exceptions\NonExistentID;
use Vundi\Potato\Exceptions\IDShouldBeNumber;

class User extends Model
{
	protected static $entity_table = 'Person';
}

Database interactions

// create a new user
$user = new User;
$user->name = "Kevin Karugu";
$user->age = 23;
$user->company = "Microsoft";
$user->save();

Get all users from the users table

$users = User::findAll(); // Returns an array of the users found in the db

Get a single user from the users table

$user = User::find(2); // will return user with an ID of 2

Edit an existing user

$user = User::find(2);
$user->name = "Devy Kerr";
$user->company = "Suyabay";
$user->update();

Delete a user

//Will remove a user from the database table
User::remove(2); // 2 represents the id of the user to be removed

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固