PHP code example of yurunsoft / sql-diff
1. Go to this page and download the library: Download yurunsoft/sql-diff library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yurunsoft / sql-diff example snippets
$sql1 = <<<SQL
CREATE TABLE `a` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
SQL;
$sql2 = <<<SQL
CREATE TABLE `a` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
SQL;
// 返回将 $sql1 结构升级到 $sql2 的 SQL 语句数组
$sqls = \Yurun\SqlDiff\SqlDiff::diff($sql1, $sql2);
var_dump($sqls);