承接 bumip/json-schema-sql 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bumip/json-schema-sql

Composer 安装命令:

composer require bumip/json-schema-sql

包简介

Helper for converting json-schemas to sql create table statement

README 文档

README

This class converts a json-schema to a valid Sql table. Tested with MySql and Sqlite. A big shoutout to @WebMaestroFr for this helper.

Installation

Just run

composer require bumip/json-schema-sql dev-master

PHP

The php version is getting tested. Delete tests/database/dbtest.db to start testing

// Instanciate PDO
$pdo = new \PDO("mysql:dbname=example;host=localhost;port=3306", "user", "password");
// Instanciate JSON_Schema_MySQL
$sql_schema = new \Bumip\JsonSchema\JsonSchemaSql($pdo);

// Or, generate table from a single .json file
$sql_schema->createTableFromFile("path/to/schema.json");

## Shell
will be changed to a proper cli tool in the future.
`php -q /path/to/json-schema-mysql/json-schema-mysql.php "mysql:dbname=example;host=localhost;port=3306" "user" "password" "/path/to/json/schema/directory"`

CRUD Class UNTESTED

A CRUD class matching the DB architecture is available. NOT TESTED.

require_once "path/to/json-schema-mysql/json-schema-crud.php";
// Instanciate PDO
$pdo = new PDO("mysql:dbname=example;host=localhost;port=3306", "user", "password");
// Instanciate JSON_Schema_MySQL
$crud = new Schema_Model($pdo, "path/to/json/schema/directory");

// Get model by id
$model = $crud->my_schema($id);
// Create model
$model = $crud->my_schema->create([
    "column_1" => "Value one",
    "column_2" => "Value two"
]);
// Get model rows
$models = $crud->my_schema->read([
    "column_1" => "First filter",
    "column_2" => "Second filter"
], [
    "order_by" => "date",
    "order"    => "DESC",
    "limit"    => 24,
    "page"     => 0
]);
// Update model
$model = $crud->my_schema->update($model->id[
    "column_1" => "New value one",
    "column_2" => "New value two"
]);
// Delete model
$crud->my_schema->delete($model->id);

Feel free to whatever. Contributions are welcome.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固