2017 © Pedro Peláez
 

library describe

Returns an array of column information from a database table.

image

rougin/describe

Returns an array of column information from a database table.

  • Thursday, April 5, 2018
  • by rougin
  • Repository
  • 2 Watchers
  • 1 Stars
  • 4,631 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 6 % Grown

The README.md

Describe

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-coverage] Total Downloads, (*1)

Describe is a PHP package that returns information about a table structure from a database., (*2)

Installation

Install Describe via Composer:, (*3)

``` bash $ composer require rougin/describe, (*4)


## Basic Usage Prior in getting information of a table structure, a vendor-specific driver must be implemented: ``` php // index.php use Rougin\Describe\Driver\MysqlDriver; $dsn = 'mysql:host=localhost;dbname=test'; $pdo = new PDO($dsn, 'root', ''); $driver = new MysqlDriver($pdo, 'test');

Below are the available drivers for specified vendors:, (*5)

Driver Description Vendor
Rougin\Describe\Driver\MysqlDriver Uses the DESCRIBE query. MySQL
Rougin\Describe\Driver\SqlServerDriver Uses the INFORMATION_SCHEMA.COLUMNS query. SQL Server
Rougin\Describe\Driver\SqliteDriver Uses the PRAGMA table_info() query. SQLite

Alternatively, the DatabaseDriver can also be used to use a vendor-specific driver based on keyword:, (*6)

``` php use Rougin\Describe\Driver\DatabaseDriver;, (*7)

$creds = array('password' => '');, (*8)

$creds['hostname'] = 'localhost'; $creds['database'] = 'test'; $creds['username'] = 'root';, (*9)

$driver = new DatabaseDriver('mysql', $creds);, (*10)


> [!NOTE] > `DatabaseDriver` is currently available to drivers `MysqlDriver` and `SqliteDriver` only. After specifying the driver, use the `columns` method to return a list of columns: ``` php // index.php /** @var \Rougin\Describe\Column[] */ $columns = $driver->columns('users');

Adding a new database driver

To add a new driver for a specified vendor, kindly implement it to a DriverInterface:, (*11)

``` php namespace Rougin\Describe\Driver;, (*12)

interface DriverInterface { /** * Returns a list of columns from a table. * * @param string $table * @return \Rougin\Describe\Column[] */ public function columns($table);, (*13)

/**
 * Returns a list of tables.
 *
 * @return \Rougin\Describe\Table[]
 */
public function tables();

}, (*14)


### Using `Table` The `Table` class is similar with the `DriverInterface` with the difference that it can return the primary key from the list of columns: ``` php use Rougin\Describe\Table; $table = new Table('users', $driver); /** @var \Rougin\Describe\Column[] */ $columns = $driver->columns(); /** @var \Rougin\Describe\Column */ $primary = $driver->primary();

For more information regarding the Column object, kindly check its code documentation., (*15)

Projects using Describe

The following projects below uses Describe as a valuable tool for getting a structure of a database table:, (*16)

Combustor is a utility package for Codeigniter 3 that generates controllers, models, and views based on the provided database tables. It uses the Describe package for getting columns from a database table and as the basis for code generation., (*17)

Refinery is a console-based package of Migrations Class for the Codeigniter 3. It uses the Describe package for retrieving the database tables for creating database migrations., (*18)

Changelog

Please see CHANGELOG for more information what has changed recently., (*19)

Testing

The unit tests for this package were written on PHPUnit:, (*20)

bash $ composer test, (*21)

Credits

License

The MIT License (MIT). Please see LICENSE for more information., (*22)

The Versions

05/04 2018

dev-master

9999999-dev https://github.com/rougin/describe

Returns an array of column information from a database table.

  Sources   Download

MIT

The Requires

 

The Development Requires

database php describe

09/01 2018

v1.7.0

1.7.0.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

database php describe

05/01 2017

v1.6.0

1.6.0.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

database php describe

12/09 2016

v1.5.1

1.5.1.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

28/07 2016

v1.5.0

1.5.0.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

27/04 2016

v1.4.2

1.4.2.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

26/04 2016

v1.4.1

1.4.1.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

23/04 2016

v1.4.0

1.4.0.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

30/03 2016

v1.3.0

1.3.0.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

24/03 2016

v1.2.2

1.2.2.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

05/11 2015

v1.2.1

1.2.1.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

21/10 2015

v1.2.0

1.2.0.0 https://github.com/rougin/describe

Get the information about the database you're working on in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

database php describe

26/07 2015

v1.1.3

1.1.3.0

Get the information about the database you're working on

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Rougin Gutib

database php describe

03/07 2015

v1.1.2

1.1.2.0

Get the information about the database you're working on

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Rougin Gutib

database php describe

26/06 2015

v1.1.1

1.1.1.0

Get the information about the database you're working on

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Rougin Gutib

database php describe

30/05 2015

v1.1.0

1.1.0.0

Get the information about the database you're working on using PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Rougin Gutib

database php describe

01/04 2015

v1.0.0

1.0.0.0

Get the information about the database you're working on using PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Rougin Gutib

database php describe