承接 com.jukusoft/php-database-table-upgrader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

com.jukusoft/php-database-table-upgrader

Composer 安装命令:

composer require com.jukusoft/php-database-table-upgrader

包简介

php-database-table-upgrader, An database upgrader for upgrade mysql table structures automatically. You dont have to write CREATE TABLE, ALTER TABLE querys and so on anymore, just configure your table structure in PHP and the classes will upgrade your table structures automatically.

README 文档

README

An database upgrader for upgrade mysql table structures automatically

Version: 0.0.1 alpha License: LGPL 3.0

Currently upgrade isnt fully integrated, but table creation should be work. Work in Progress!

Requirements

  • PHP 7.0.8+
  • MySQL 5.7+

Configuration

If you want to use the build-in MySQLDriver, you have to copy config/mysql.examplecfg.php to mysql.cfg.php and change values.

Supported Data Types

  • INT
  • VARCHAR
  • TEXT
  • CHAR
  • TINYTEXT
  • MEDIUMTEXT
  • LONGTEXT (4294967295 characters)
  • BIT
  • BINARY
  • TINYINT
  • SMALLINT
  • MEDIUMINT
  • BIGINT
  • DECIMAL
  • NUMERIC
  • DOUBLE
  • FLOAT
  • REAL
  • BLOB
  • TINYBLOB
  • MEDIUMBLOB
  • LONGBLOB
  • ENUM
  • SET
  • DATE
  • TIME
  • YEAR
  • TIMESTAMP
  • DATETIME
  • JSON

Supported Keys and Indexes

  • PRIMARY KEY

  • INDEX

  • UNIQUE

  • SPATIAL

  • FULLTEXT

  • FOREIGN KEY

  • more are Work in Progress

Example

Generate CREATE TABLE query:

//create or upgrade test table
$table = new DBTable("test", $dbDriver);
$table->setEngine("InnoDB");
$table->setCharset("utf8");

//add int coloum
$table->addInt("id");

//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
$table->addInt("testint", 10, true, true);

//add varchar column
$table->addVarchar("test_text", 255, true, "default value");

//add text column
$table->addText("text");

//print CREATE statement for debugging
echo $table->generateCreateQuery();

prints following query:

CREATE TABLE `{DBPRAEFIX}test` IF NOT EXISTS (
`id` INT,
`testint` INT(10) NOT NULL AUTO_INCREMENT,
`test_text` VARCHAR(255) NOT NULL DEFAULT 'default value',
`text` TEXT
) TYPE=InnoDB DEFAULT CHARSET=utf8;

How to add an PRIMARY KEY

PRIMARY with only 1 column:

//add primary key
$table->addPrimaryKey("column_name");

PRIMARY KEY with more than 1 column:

//add primary key
$table->addPrimaryKey(array("id", "testint"));

Because PRIMARY KEYS are limited to specific length, you can also specifiy length of columns used in PRIMARY KEY:

//add primary key
$table->addPrimaryKey(array("id", "testint", array('column' => "test_text", 'length' => 50)));

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL
  • 更新时间: 2016-08-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固