2017 © Pedro Peláez
 

library sqlite-parser

sqlite table schema parser

image

maghead/sqlite-parser

sqlite table schema parser

  • Monday, February 5, 2018
  • by c9s
  • Repository
  • 1 Watchers
  • 5 Stars
  • 555 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 6 Versions
  • 3 % Grown

The README.md

Maghead Sqlite Parser

Build Status Coverage Status Latest Stable Version Total Downloads Monthly Downloads Daily Downloads Latest Unstable Version License Join the chat at https://gitter.im/maghead/sqlite-parser Works On My Machine Made in Taiwan, (*1)

SYNOPSIS


use Maghead\SqliteParser\CreateTableParser; $sql = 'CREATE TEMP TABLE `foo` (`a` INT DEFAULT 0, name VARCHAR, address VARCHAR, CONSTRAINT address_idx UNIQUE(name, address))'; $parser = new CreateTableParser; $def = $parser->parse($sql); foreach ($def->columns as $c) { echo $c->name; echo $c->type; echo $c->primary; } $this->assertCount(1, $def->constraints); $this->assertInstanceOf('Maghead\\SqliteParser\\Constraint', $def->constraints[0]); $this->assertEquals('address_idx', $def->constraints[0]->name); $this->assertCount(2, $def->constraints[0]->unique);

INSTALL

composer require maghead/sqlite-parser

USAGE

Just simply call the parse method and you will get what you want., (*2)

var_dump is your friend. :-), (*3)

class Maghead\SqliteParser\Table#2 (5) {
  public $columns =>
  array(1) {
    [0] =>
    class Maghead\SqliteParser\Column#6 (13) {
      public $name =>
      string(1) "a"
      public $type =>
      string(3) "INT"
      public $length =>
      NULL
      public $decimals =>
      NULL
      public $unsigned =>
      bool(false)
      public $primary =>
      NULL
      public $ordering =>
      NULL
      public $autoIncrement =>
      NULL
      public $unique =>
      NULL
      public $notNull =>
      NULL
      public $default =>
      int(-20)
      public $collate =>
      NULL
      public $references =>
      NULL
    }
  }
  public $temporary =>
  bool(true)
  public $ifNotExists =>
  bool(false)
  public $tableName =>
  string(3) "foo"
  public $constraints =>
  array(1) {
    [0] =>
    class Maghead\SqliteParser\Constraint#8 (4) {
      public $name =>
      string(2) "aa"
      public $primaryKey =>
      NULL
      public $unique =>
      array(1) {
        [0] =>
        class stdClass#13 (2) {
          public $name =>
          string(1) "a"
          public $ordering =>
          string(3) "ASC"
        }
      }
      public $foreignKey =>
      NULL
    }
  }
}

LICENSE

MIT LICENSE, (*4)

The Versions

05/02 2018

dev-master

9999999-dev https://github.com/maghead/sqlite-parser

sqlite table schema parser

  Sources   Download

MIT

The Requires

  • php >=5.6

 

database sql parser sqlite

10/06 2017

4.0.4

4.0.4.0 https://github.com/maghead/sqlite-parser

sqlite table schema parser

  Sources   Download

MIT

The Requires

  • php >=5.6

 

database sql parser sqlite

06/06 2017

4.0.3

4.0.3.0 https://github.com/maghead/sqlite-parser

sqlite table schema parser

  Sources   Download

MIT

The Requires

  • php >=5.6

 

database sql parser sqlite

06/06 2017

4.0.2

4.0.2.0 https://github.com/maghead/sqlite-parser

sqlite table schema parser

  Sources   Download

MIT

The Requires

  • php >=5.6

 

database sql parser sqlite

13/05 2017

4.0.1

4.0.1.0 https://github.com/maghead/sqlite-parser

sqlite table schema parser

  Sources   Download

MIT

The Requires

  • php >=7.0

 

database sql parser sqlite

13/05 2017

4.0.0

4.0.0.0 https://github.com/maghead/sqlite-parser

sqlite table schema parser

  Sources   Download

MIT

The Requires

  • php >=7.0

 

database sql parser sqlite