当前位置: 首页>>代码示例>>PHP>>正文


PHP BigTree::tableCompare方法代码示例

本文整理汇总了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;
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:create.php


注:本文中的BigTree::tableCompare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。