PHPackages                             samshal/scripd - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. samshal/scripd

ActiveLibrary[Database &amp; ORM](/categories/database)

samshal/scripd
==============

Easily transfer database structures as json documents, or via rest apis

v1.0.1(10y ago)11572MITPHPPHP ^5.3 || ^7.0

Since Apr 26Pushed 9y ago3 watchersCompare

[ Source](https://github.com/Samshal/Scripd)[ Packagist](https://packagist.org/packages/samshal/scripd)[ RSS](/packages/samshal-scripd/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (6)Used By (0)

Scripd [![Build Status](https://camo.githubusercontent.com/81662f9d6e6edad23979c969ec441f3bc9085c18d7cb8a16fb565b7c88dd91b7/68747470733a2f2f7472617669732d63692e6f72672f53616d7368616c2f5363726970642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Samshal/Scripd) [![Latest Stable Version](https://camo.githubusercontent.com/038eaedc74c863930196144af5813687ad507f042c23fe93c73a613a80c8f1a1/68747470733a2f2f706f7365722e707567782e6f72672f73616d7368616c2f7363726970642f762f737461626c65)](https://packagist.org/packages/samshal/scripd) [![Total Downloads](https://camo.githubusercontent.com/3dd668f0d2c2c3c5d95b4d122b45d206870bdc2fca8d37a35d3cb07d97a67cc1/68747470733a2f2f706f7365722e707567782e6f72672f73616d7368616c2f7363726970642f646f776e6c6f616473)](https://packagist.org/packages/samshal/scripd) [![Latest Unstable Version](https://camo.githubusercontent.com/7efecbae698e60757ed3a1e4b9b1e50a6121799c886400caaaa6c32d1389194b/68747470733a2f2f706f7365722e707567782e6f72672f73616d7368616c2f7363726970642f762f756e737461626c65)](https://packagist.org/packages/samshal/scripd) [![License](https://camo.githubusercontent.com/b3ce64ff29e3436cbe12ba10bdfd6484b6f5c64df12263ddc7941112ea00604f/68747470733a2f2f706f7365722e707567782e6f72672f73616d7368616c2f7363726970642f6c6963656e7365)](https://packagist.org/packages/samshal/scripd) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/b351f28a8a798babc8433087272723d937385a3f0ca5f8949050caacb39f1eb3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53616d7368616c2f5363726970642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Samshal/Scripd/?branch=master) [![StyleCI](https://camo.githubusercontent.com/39cc725a45253efa6ca335591d4cce3525e24a6aa0de2841bf43da0b37e3c8c8/68747470733a2f2f7374796c6563692e696f2f7265706f732f35363735353532302f736869656c64)](https://styleci.io/repos/56755520)
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#scripd-------)

A robust SQL Generator. Parses database structures defined in json based on a custom jsyn file format and generates corresponding sql queries.

Class Features
--------------

[](#class-features)

- 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
- Much More!

Why you might need it
---------------------

[](#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

License
-------

[](#license)

This software is distributed under the [MIT](https://opensource.org/licenses/MIT) license. Please read LICENSE for information on the software availability and distribution.

Installation &amp; loading
--------------------------

[](#installation--loading)

Scripd is available via [Composer/Packagist](https://packagist.org/packages/samshal/scripd), so just add this line to your `composer.json` file:

```
"samshal/scripd": "~1.0"
```

or

```
composer require samshal/scripd
```

A Simple Example
----------------

[](#a-simple-example)

#### JSON DB Structure (structure.json)

[](#json-db-structure-structurejson)

```
{
	":database":{
		":crud-action":"create",
		"name":"dbname",

		":table":[
			{
				":crud-action":"create",
				"name":"students",
				"columns":[
					{
						"name":"id",
						"data-type":"int",
						"primary-key":true
					},
					{
						"name":"first_name",
						"data-type":"varchar(20)",
						"default":"'samuel'"
					},
					{
						"name":"last_name",
						"data-type":"varchar(20)"
					},
					{
						"name":"class",
						"data-type":"varchar(10)"
					}
				]
			}
		]
	}
}
```

#### PHP (index.php)

[](#php-indexphp)

```
