定制 maghead/sqlite-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maghead/sqlite-parser

Composer 安装命令:

composer require maghead/sqlite-parser

包简介

sqlite table schema parser

README 文档

README

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

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.

var_dump is your friend. :-)

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

统计信息

  • 总下载量: 827
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固