This package can generate database creation SQL queries from JSON.
It takes a file in JSYN format (JSON) and parses it to extract a list of commands for database creation.
The main class can generate SQL queries for creating or modifying database structures like databases, tables, views, indexes, trigger, functions, stored procedures, etc..
The generated SQL is compatible with several databases like MySQL, SQLite, Microsoft SQL server, etc..
Prize: SourceGuarding PHP encoder tool
|Every SQL database driven application needs to update the database schema once in a while to support new features.
This class can perform that process of generating SQL for database updates with elegance, as it allows developers to define database schema additions in a JSON based file format, so it can work with different types of databases.
Since the format is based in JSON it can be used eventually by similar packages written in other languages.
Not only it supports the creation and modification of databases, tables and indexes, but it also supports triggers, views, stored procedures and functions.
A robust SQL Generator. Parses database structures defined in json based on a custom jsyn file format and generates corresponding sql queries.
A json like file format to define database structure
Support for multiple sql vendors / dialects
Compatible with PHP 5.0+
Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
Why you might need it
This project was birthed as a result of the need to give users an opportunity to
create their own custom database structure in a PHP Application.
I wanted users to be able to modify database structures while there is support for multiple db vendors such as mysql, sqlite and sql server.
This library offers the ability to create database structures in a json-like format and generate sql compatible with several database vendors.
It is also very easy to use and integrate into your php based projects
This software is distributed under the MIT license. Please read LICENSE for information on the
software availability and distribution.
Installation & loading
Scripd is available via Composer/Packagist, so just add this line to your
composer require samshal/scripd
A Simple Example
JSON DB Structure (structure.json)
$jsonDBStructure = new Samshal\Scripd\JsonDbStructure('./structure.json', 'mysql');
$sql = $jsonDBStructure->getGeneratedSql();