2017 © Pedro Peláez
 

library db-reflector

Allows a cross-vendor API to view database schema information

image

verysimple/db-reflector

Allows a cross-vendor API to view database schema information

  • Wednesday, February 17, 2016
  • by jasonhinkle
  • Repository
  • 2 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Verysimple DB Reflector

DB Reflector inspects a database schema and converts it into a simple collection of arrays and objects that can be easily inspected. This includes information about columns, keys and table relationships., (*1)

DB Reflector neutralizes vendor-specific information and provides a consistent schema for all supported databases. Some possible uses for this Reflector are for building a generic DB editor or a code generator., (*2)

Databases currently supported are MySQL and Postgres. SQLite is being worked on., (*3)

Available on packagist.org., (*4)

Installation

Install DB Reflector class with composer:, (*5)

composer require verysimple/db-reflector

For automatic installation, include the project in your composer.json (it is only necessary in require-dev):, (*6)

{
    "require-dev": {
        "verysimple/db-reflector": ">=1.0.0"
    }
}

Usage

// the reflector object handles the connection
$r = new Reflector('dsn', 'username', 'password');

// The DB name is specified in the DSN
$db = $r->getDB();

// enumerate through all of the tables
foreach ($tables as $table) {

    // getPrimaryKey returns an array of 0 or more Column objects
    $key = $table->getPrimaryKey();

    // columns is an array of Column objects
    $columns = $table->GetColumns();

    // relationships is an array of Relationship objects
    $relationships = $table->getRelationships();

}

Running Unit Tests

First clone repository. For first initial install:, (*7)

composer install

To refresh autoloader:, (*8)

composer dumpautoload
  • Run DB setup scripts in /assets/sql
  • create file phpunit_connection.php in root directory
  • see phpunit_bootstrap.php for instructions

The Versions

17/02 2016

dev-master

9999999-dev https://github.com/verysimple/db-reflector

Allows a cross-vendor API to view database schema information

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

schema php postgresql reflection mysql

05/01 2016

1.0.0

1.0.0.0

Cross-Platform DB Reflection

  Sources   Download

The Requires

  • php >=5.4.0

 

The Development Requires