當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。