本文整理汇总了PHP中BigTree::tableCompare方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::tableCompare方法的具体用法?PHP BigTree::tableCompare怎么用?PHP BigTree::tableCompare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::tableCompare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_decode
$existing_json = json_decode($existing["manifest"], true);
// Increment revision numbers
$revision = $package["revision"] = intval($existing_json["revision"]) + 1;
$package["sql_revisions"] = (array) $existing_json["sql_revisions"];
$package["sql_revisions"][$revision] = array();
// Diff the old tables
foreach ($existing_json["components"]["tables"] as $table => $create_statement) {
// If the table exists in the new manifest, we're going to see if they're identical
if (isset($package["components"]["tables"][$table])) {
// We're going to create a temporary table of the old structure to compare to the current table
$create_statement = preg_replace("/CREATE TABLE `([^`]*)`/i", "CREATE TABLE `bigtree_extension_temp`", $create_statement);
$create_statement = preg_replace("/CONSTRAINT `([^`]*)`/i", "", $create_statement);
sqlquery("DROP TABLE IF EXISTS `bigtree_extension_temp`");
sqlquery($create_statement);
// Compare the tables, if we have changes to make, store them in a SQL revisions portion of the manifest
$transition_statements = BigTree::tableCompare("bigtree_extension_temp", $table);
foreach ($transition_statements as $statement) {
// Don't include changes to auto increment
if (stripos($statement, "auto_increment = ") === false) {
$package["sql_revisions"][$revision][] = str_replace("`bigtree_extension_temp`", "`{$table}`", $statement);
}
}
// Table doesn't exist in the new manifest, so we're going to drop it
} else {
$package["sql_revisions"][$revision][] = "DROP TABLE IF EXISTS `{$table}`";
}
}
// Add new tables that don't exist in the old manifest
foreach ($package["components"]["tables"] as $table => $create_statement) {
if (!isset($existing_json["components"]["tables"][$table])) {
$package["sql_revisions"][$revision][] = $create_statement;