PHPackages                             jpuck/qdbp - 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. jpuck/qdbp

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

jpuck/qdbp
==========

Quick Databases for PHP

2.0.11(8y ago)046[7 issues](https://github.com/jpuck/qdbp/issues)MITPHPPHP ^7.0

Since Jun 24Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jpuck/qdbp)[ Packagist](https://packagist.org/packages/jpuck/qdbp)[ RSS](/packages/jpuck-qdbp/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)Dependencies (3)Versions (26)Used By (0)

Quick Databases for PHP
=======================

[](#quick-databases-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/4dcf9b7fb3557bda179e3f2bd04d156717028da0ef7eca275655def386fc9843/68747470733a2f2f706f7365722e707567782e6f72672f6a7075636b2f716462702f762f737461626c65)](https://packagist.org/packages/jpuck/qdbp)[![Total Downloads](https://camo.githubusercontent.com/6b64d322ce4bab419c9eb00b77de3334269cb193a564ab684d764dd2e1e82fa4/68747470733a2f2f706f7365722e707567782e6f72672f6a7075636b2f716462702f646f776e6c6f616473)](https://packagist.org/packages/jpuck/qdbp)[![License](https://camo.githubusercontent.com/f67ed7d913f8fce90701b46dff0db51909f1bef61bbcd0a9a1722e6007a7ab54/68747470733a2f2f706f7365722e707567782e6f72672f6a7075636b2f716462702f6c6963656e7365)](https://packagist.org/packages/jpuck/qdbp)

PHP7 command line console application to create/drop databases &amp; users as well as execute lists of SQL scripts. This will also generate a PHP file that returns an instance of [PDO](http://php.net/manual/en/book.pdo.php).

Currently supports creating MySQL environments with a default character set of UTF-8 and utf8\_unicode\_ci collation.

The purge command is for Microsoft SQL Server.

Please report all bugs on the [Github issues page](https://github.com/jpuck/qdbp/issues).

Environments
------------

[](#environments)

- Development
    - user with all privileges
- Testing Quality Assurance
    - user with all privileges
    - user with only stored procedure execute privileges
- Production
    - user with only stored procedure execute privileges

Naming Schema
-------------

[](#naming-schema)

Database names begin with a maximum 7 character name of your choosing, and end with a randomly generated 5 character identifier. The first letter of the ID designates its environment `D` (Development), `T` (Test), or `P` (Production).

This allows you to easily spin up alternate environments for development and testing on the same server without conflict.

Usernames are the same as the database name ending with an `_A` or an `_E` to designate permissions (All or Execute respectively). The privileged accounts ending with `_A` (User ALL) are intended for use with [DDL](https://en.wikipedia.org/wiki/Data_definition_language) in development and testing. The execute only accounts are designated by `_E` (User EXECUTE) and are intended for use by the application in testing and production. This follows the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege) whereby all [DML](https://en.wikipedia.org/wiki/Data_manipulation_language) is wrapped within explicit parameterized stored procedures.

The reason names are limited to 7 characters is because up until MySQL 5.7.8 [usernames could only be 16 characters long](http://dev.mysql.com/doc/refman/5.7/en/user-names.html). Now they can be 32, but this application currently constrains that for backwards compatibility.

### Examples

[](#examples)

- Development
    - Database: `example_D4JAOb`
    - Privileged User: `example_D4JAOb_A`
- Test
    - Database: `example_TzWwAo`
    - Privileged User: `example_TzWwAo_A`
    - Application User: `example_TzWwAo_E`
- Production
    - Database: `example_PNITvJ`
    - Application User: `example_PNITvJ_E`

The generated PHP file will return an instance of PDO and looks like this:

```
