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


PHP BigTree::describeTable方法代码示例

本文整理汇总了PHP中BigTree::describeTable方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::describeTable方法的具体用法?PHP BigTree::describeTable怎么用?PHP BigTree::describeTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigTree的用法示例。


在下文中一共展示了BigTree::describeTable方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _local_bigtree_update_200

function _local_bigtree_update_200()
{
    global $cms, $admin;
    // Drop unused comments column
    sqlquery("ALTER TABLE bigtree_pending_changes DROP COLUMN `comments`");
    // Add extension columns
    sqlquery("ALTER TABLE bigtree_callouts ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_callouts ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    sqlquery("ALTER TABLE bigtree_feeds ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_feeds ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    sqlquery("ALTER TABLE bigtree_field_types ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_field_types ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    sqlquery("ALTER TABLE bigtree_modules ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_modules ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    sqlquery("ALTER TABLE bigtree_module_groups ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_module_groups ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    sqlquery("ALTER TABLE bigtree_settings ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_settings ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    sqlquery("ALTER TABLE bigtree_templates ADD COLUMN `extension` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_templates ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE");
    // New publish_hook column, consolidate other hooks into one column
    sqlquery("ALTER TABLE bigtree_pending_changes ADD COLUMN `publish_hook` VARCHAR(255)");
    sqlquery("ALTER TABLE bigtree_module_forms ADD COLUMN `hooks` TEXT");
    sqlquery("ALTER TABLE bigtree_module_embeds ADD COLUMN `hooks` TEXT");
    $q = sqlquery("SELECT * FROM bigtree_module_forms");
    while ($f = sqlfetch($q)) {
        $hooks = array();
        $hooks["pre"] = $f["preprocess"];
        $hooks["post"] = $f["callback"];
        $hooks["publish"] = "";
        sqlquery("UPDATE bigtree_module_forms SET hooks = '" . BigTree::json($hooks, true) . "' WHERE id = '" . $f["id"] . "'");
    }
    $q = sqlquery("SELECT * FROM bigtree_module_embeds");
    while ($f = sqlfetch($q)) {
        $hooks = array();
        $hooks["pre"] = $f["preprocess"];
        $hooks["post"] = $f["callback"];
        $hooks["publish"] = "";
        sqlquery("UPDATE bigtree_module_embeds SET hooks = '" . BigTree::json($hooks, true) . "' WHERE id = '" . $f["id"] . "'");
    }
    sqlquery("ALTER TABLE bigtree_module_forms DROP COLUMN `preprocess`");
    sqlquery("ALTER TABLE bigtree_module_forms DROP COLUMN `callback`");
    sqlquery("ALTER TABLE bigtree_module_embeds DROP COLUMN `preprocess`");
    sqlquery("ALTER TABLE bigtree_module_embeds DROP COLUMN `callback`");
    // Adjust groups/callouts for multi-support -- first we drop the foreign key
    $table_desc = BigTree::describeTable("bigtree_callouts");
    foreach ($table_desc["foreign_keys"] as $name => $definition) {
        if ($definition["local_columns"][0] === "group") {
            sqlquery("ALTER TABLE bigtree_callouts DROP FOREIGN KEY `{$name}`");
        }
    }
    // Add the field to the groups
    sqlquery("ALTER TABLE bigtree_callout_groups ADD COLUMN `callouts` TEXT AFTER `name`");
    // Find all the callouts in each group
    $q = sqlquery("SELECT * FROM bigtree_callout_groups");
    while ($f = sqlfetch($q)) {
        $callouts = array();
        $qq = sqlquery("SELECT * FROM bigtree_callouts WHERE `group` = '" . $f["id"] . "' ORDER BY position DESC, id ASC");
        while ($ff = sqlfetch($qq)) {
            $callouts[] = $ff["id"];
        }
        sqlquery("UPDATE bigtree_callout_groups SET `callouts` = '" . BigTree::json($callouts, true) . "' WHERE id = '" . $f["id"] . "'");
    }
    // Drop the group column
    sqlquery("ALTER TABLE bigtree_callouts DROP COLUMN `group`");
    // Security policy setting
    sqlquery("INSERT INTO `bigtree_settings` (`id`,`value`,`system`) VALUES ('bigtree-internal-security-policy','{}','on')");
    sqlquery("CREATE TABLE `bigtree_login_attempts` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `ip` int(11) DEFAULT NULL, `user` int(11) DEFAULT NULL, `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8");
    sqlquery("CREATE TABLE `bigtree_login_bans` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `ip` int(11) DEFAULT NULL, `user` int(11) DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `expires` datetime DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8");
    // Media settings
    sqlquery("INSERT INTO `bigtree_settings` (`id`,`value`,`system`) VALUES ('bigtree-internal-media-settings','{}','on')");
    // New field types
    @unlink(SERVER_ROOT . "cache/bigtree-form-field-types.json");
    // Setup an anonymous function for converting a resource set
    $resource_converter = function ($resources) {
        $new_resources = array();
        foreach ($resources as $item) {
            // Array of Items no longer exists, switching to Matrix
            if ($item["type"] == "array") {
                $item["type"] = "matrix";
                $item["columns"] = array();
                $x = 0;
                foreach ($item["fields"] as $field) {
                    $x++;
                    $item["columns"][] = array("id" => $field["key"], "type" => $field["type"], "title" => $field["title"], "display_title" => $x == 1 ? "on" : "");
                }
                unset($item["fields"]);
            }
            $r = array("id" => $item["id"], "type" => $item["type"], "title" => $item["title"], "subtitle" => $item["subtitle"], "options" => array());
            foreach ($item as $key => $val) {
                if ($key != "id" && $key != "title" && $key != "subtitle" && $key != "type") {
                    $r["options"][$key] = $val;
                }
            }
            $new_resources[] = $r;
        }
        return BigTree::json($new_resources, true);
    };
    $field_converter = function ($fields) {
        $new_fields = array();
//.........这里部分代码省略.........
开发者ID:kalle0045,项目名称:BigTree-CMS,代码行数:101,代码来源:database.php

示例2: search

 function search($query, $order = false, $limit = false, $split_search = false, $case_sensitive = false, $columns = false)
 {
     $table_description = BigTree::describeTable($this->Table);
     $where = array();
     if ($split_search) {
         $pieces = explode(" ", $query);
         foreach ($pieces as $piece) {
             if ($piece) {
                 $where_piece = array();
                 foreach ($table_description["columns"] as $field => $parameters) {
                     if ($case_sensitive) {
                         $where_piece[] = "`{$field}` LIKE '%" . sqlescape($piece) . "%'";
                     } else {
                         $where_piece[] = "LOWER(`{$field}`) LIKE '%" . sqlescape(strtolower($piece)) . "%'";
                     }
                 }
                 $where[] = "(" . implode(" OR ", $where_piece) . ")";
             }
         }
         return $this->fetch($order, $limit, implode(" AND ", $where), $columns);
     } else {
         foreach ($table_description["columns"] as $field => $parameters) {
             if ($case_sensitive) {
                 $where[] = "`{$field}` LIKE '%" . sqlescape($query) . "%'";
             } else {
                 $where[] = "LOWER(`{$field}`) LIKE '%" . sqlescape(strtolower($query)) . "%'";
             }
         }
         return $this->fetch($order, $limit, implode(" OR ", $where), $columns);
     }
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:modules.php

示例3: updateItem

 static function updateItem($table, $id, $data, $many_to_many = array(), $tags = array())
 {
     $table_description = BigTree::describeTable($table);
     $query = "UPDATE `{$table}` SET ";
     foreach ($data as $key => $val) {
         if (array_key_exists($key, $table_description["columns"])) {
             if ($val === "NULL" || $val == "NOW()") {
                 $query .= "`{$key}` = {$val},";
             } else {
                 if (is_array($val)) {
                     $val = json_encode(BigTree::translateArray($val));
                 }
                 $query .= "`{$key}` = '" . sqlescape($val) . "',";
             }
         }
     }
     $query = rtrim($query, ",") . " WHERE id = '{$id}'";
     sqlquery($query);
     // Handle many to many
     if (!empty($many_to_many)) {
         foreach ($many_to_many as $mtm) {
             sqlquery("DELETE FROM `" . $mtm["table"] . "` WHERE `" . $mtm["my-id"] . "` = '{$id}'");
             $table_description = BigTree::describeTable($mtm["table"]);
             if (is_array($mtm["data"])) {
                 $x = count($mtm["data"]);
                 foreach ($mtm["data"] as $item) {
                     if (isset($table_description["columns"]["position"])) {
                         sqlquery("INSERT INTO `" . $mtm["table"] . "` (`" . $mtm["my-id"] . "`,`" . $mtm["other-id"] . "`,`position`) VALUES ('{$id}','{$item}','{$x}')");
                     } else {
                         sqlquery("INSERT INTO `" . $mtm["table"] . "` (`" . $mtm["my-id"] . "`,`" . $mtm["other-id"] . "`) VALUES ('{$id}','{$item}')");
                     }
                     $x--;
                 }
             }
         }
     }
     // Handle the tags
     sqlquery("DELETE FROM bigtree_tags_rel WHERE `table` = '" . sqlescape($table) . "' AND entry = '{$id}'");
     if (!empty($tags)) {
         foreach ($tags as $tag) {
             sqlquery("DELETE FROM bigtree_tags_rel WHERE `table` = '" . sqlescape($table) . "' AND entry = {$id} AND tag = {$tag}");
             sqlquery("INSERT INTO bigtree_tags_rel (`table`,`entry`,`tag`) VALUES ('" . sqlescape($table) . "',{$id},{$tag})");
         }
     }
     // Clear out any pending changes.
     sqlquery("DELETE FROM bigtree_pending_changes WHERE item_id = '{$id}' AND `table` = '{$table}'");
     if ($table != "bigtree_pages") {
         self::recacheItem($id, $table);
     }
     self::track($table, $id, "updated");
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:51,代码来源:auto-modules.php

示例4: array

     $list = array();
     foreach ($column["options"] as $option) {
         $list[] = array("value" => $option, "description" => $option);
     }
     $options = array("list_type" => "static", "list" => $list);
     if ($column["allow_null"]) {
         $options["allow-empty"] = "Yes";
     } else {
         $options["allow-empty"] = "No";
     }
 }
 // Database populated list for foreign keys.
 if (substr($column["type"], -3, 3) == "int" && isset($foreign_keys[$column["name"]]) && implode("", $foreign_keys[$column["name"]]["other_columns"]) == "id") {
     $type = "list";
     // Describe this other table
     $other_table = BigTree::describeTable($foreign_keys[$column["name"]]["other_table"]);
     $ot_columns = $other_table["columns"];
     $desc_column = "";
     // Find the first short title-esque column and use it as the populated list descriptor
     while (!$desc_column && next($ot_columns)) {
         $col = current($ot_columns);
         if (($col["type"] == "varchar" || $col["type"] == "char") && $col["size"] > 2) {
             $desc_column = $col;
         }
     }
     $options = array("list_type" => "db", "pop-table" => $foreign_keys[$column["name"]]["other_table"]);
     if ($desc_column) {
         $options["pop-description"] = $desc_column["name"];
         $options["pop-sort"] = $desc_column["name"] . " ASC";
     }
     if ($column["allow_null"]) {
开发者ID:kalle0045,项目名称:BigTree-CMS,代码行数:31,代码来源:load-form.php

示例5: array

<?php

if ($_GET["table"]) {
    $table = $_GET["table"];
}
$used = array();
$unused = array();
$tblfields = array();
// To tolerate someone selecting the blank spot again when creating a feed.
if ($table) {
    $table_description = BigTree::describeTable($table);
} else {
    $table_description = array("columns" => array());
}
foreach ($table_description["columns"] as $column => $details) {
    $tblfields[] = $column;
}
if (isset($fields)) {
    foreach ($fields as $key => $field) {
        $used[] = $key;
    }
    // Figure out the fields we're not using so we can offer them back.
    foreach ($tblfields as $field) {
        if (!in_array($field, $used)) {
            $unused[] = array("title" => ucwords(str_replace("_", " ", $field)), "field" => $field);
        }
    }
} else {
    $fields = array();
    foreach ($tblfields as $f) {
        $title = ucwords(str_replace(array("-", "_"), " ", $f));
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:load-feed-fields.php

示例6: updateModuleViewColumnNumericStatus

 static function updateModuleViewColumnNumericStatus($view)
 {
     if (is_array($view["fields"])) {
         $form = BigTreeAutoModule::getRelatedFormForView($view);
         $table = BigTree::describeTable($view["table"]);
         foreach ($view["fields"] as $key => $field) {
             $numeric = false;
             $t = $table["columns"][$key]["type"];
             if ($t == "int" || $t == "float" || $t == "double" || $t == "double precision" || $t == "tinyint" || $t == "smallint" || $t == "mediumint" || $t == "bigint" || $t == "real" || $t == "decimal" || $t == "dec" || $t == "fixed" || $t == "numeric") {
                 $numeric = true;
             }
             if ($field["parser"] || $form["fields"][$key]["type"] == "list" && $form["fields"][$key]["list_type"] == "db") {
                 $numeric = false;
             }
             $view["fields"][$key]["numeric"] = $numeric;
         }
         $fields = BigTree::json($view["fields"], true);
         sqlquery("UPDATE bigtree_module_views SET fields = '{$fields}' WHERE id = '" . $view["id"] . "'");
     }
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:20,代码来源:admin.php

示例7: _localDrawLevel

            }
            if (count($children)) {
                if ($expanded) {
                    echo "<ul>";
                } else {
                    echo '<ul style="display: none;">';
                }
                _localDrawLevel($children, $depth + 1);
                echo "</ul>";
            }
            ?>
</li>
<?php 
        }
    }
    $table_description = BigTree::describeTable($bigtree["view"]["table"]);
    if ($table_description["columns"][$bigtree["view"]["options"]["nesting_column"]]["allow_null"]) {
        _localDrawLevel(BigTreeAutoModule::getViewDataForGroup($bigtree["view"], "", "position DESC, id ASC", "both"), 1);
    } else {
        _localDrawLevel(BigTreeAutoModule::getViewDataForGroup($bigtree["view"], "0", "position DESC, id ASC", "both"), 1);
    }
    ?>
<script>
	$("#nested_container").addClass("nested_table");
	<?php 
    if ($permission == "p") {
        ?>
	BigTree.localCreateSortable("#table_data");
	<?php 
    }
    ?>
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:nested.php

示例8: foreach

    $table_description = BigTree::describeTable($table);
    foreach ($table_description["columns"] as $column => $details) {
        if (!in_array($column, $used_fields)) {
            $unused_fields[] = array("field" => $column, "title" => str_replace(array("Url", "Pdf", "Sql"), array("URL", "PDF", "SQL"), ucwords(str_replace(array("-", "_"), " ", $details["name"]))));
        }
        if (!in_array($column, $used_filters)) {
            $unused_filters[] = array("field" => $column, "title" => str_replace(array("Url", "Pdf", "Sql"), array("URL", "PDF", "SQL"), ucwords(str_replace(array("-", "_"), " ", $details["name"]))));
        }
        $table_columns[] = $column;
    }
} else {
    $fields = array();
    $filters = array();
    // To tolerate someone selecting the blank spot in the table dropdown again when creating a form.
    if ($table) {
        $table_info = BigTree::describeTable($table);
    } else {
        $table_info = array("foreign_keys" => array(), "columns" => array());
    }
    foreach ($table_info["columns"] as $column) {
        $table_columns[] = $column["name"];
        $title = str_replace(array("Url", "Pdf", "Sql"), array("URL", "PDF", "SQL"), ucwords(str_replace(array("-", "_"), " ", $column["name"])));
        $fields[$column["name"]] = $title;
        $type = "search";
        if ($column["type"] == "date" || $column["type"] == "datetime" || $column["type"] == "timestamp") {
            $type = "date-range";
        }
        if ($column["name"] == "approved" || $column["name"] == "archived" || $column["name"] == "featured") {
            $type = "boolean";
        }
        $filters[$column["name"]] = array("title" => $title, "type" => $type);
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:load-report.php

示例9: tableContents

 static function tableContents($table)
 {
     $inserts = array();
     // Figure out which columns are binary and need to be pulled as hex
     $description = BigTree::describeTable($table);
     $column_query = array();
     $binary_columns = array();
     foreach ($description["columns"] as $key => $column) {
         if ($column["type"] == "tinyblob" || $column["type"] == "blob" || $column["type"] == "mediumblob" || $column["type"] == "longblob" || $column["type"] == "binary" || $column["type"] == "varbinary") {
             $column_query[] = "HEX(`{$key}`) AS `{$key}`";
             $binary_columns[] = $key;
         } else {
             $column_query[] = "`{$key}`";
         }
     }
     // Get the rows out of the table
     $qq = sqlquery("SELECT " . implode(", ", $column_query) . " FROM `{$table}`");
     while ($ff = sqlfetch($qq)) {
         $keys = array();
         $vals = array();
         foreach ($ff as $key => $val) {
             $keys[] = "`{$key}`";
             if ($val === null) {
                 $vals[] = "NULL";
             } else {
                 if (in_array($key, $binary_columns)) {
                     $vals[] = "X'" . str_replace("\n", "\\n", sqlescape($val)) . "'";
                 } else {
                     $vals[] = "'" . str_replace("\n", "\\n", sqlescape($val)) . "'";
                 }
             }
         }
         $inserts[] = "INSERT INTO `{$table}` (" . implode(",", $keys) . ") VALUES (" . implode(",", $vals) . ")";
     }
     return $inserts;
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:36,代码来源:utils.php

示例10: foreach

        $total_results++;
    }
}
if (count($pages)) {
    $results["Pages"] = $pages;
}
// Get every module's results based on auto module views.
$modules = $admin->getModules("name ASC");
foreach ($modules as $m) {
    // Get all auto module view actions for this module.
    $actions = $admin->getModuleActions($m);
    foreach ($actions as $action) {
        if ($action["view"]) {
            $view = BigTreeAutoModule::getView($action["view"]);
            $m_results = array();
            $table_description = BigTree::describeTable($view["table"]);
            $qparts = array();
            foreach ($table_description["columns"] as $column => $data) {
                $qparts[] = "`{$column}` LIKE {$w}";
            }
            // Get matching results
            $qs = sqlquery("SELECT * FROM `" . $view["table"] . "` WHERE " . implode(" OR ", $qparts));
            // Ignore SQL failures because we might have bad collation.
            while ($r = sqlfetch($qs, true)) {
                foreach ($r as &$piece) {
                    $piece = $cms->replaceInternalPageLinks($piece);
                }
                unset($piece);
                $m_results[] = $r;
                $total_results++;
            }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:search.php

示例11: array

<?php

// Find out whether this is a draggable Many to Many.
$table_description = BigTree::describeTable($field["options"]["mtm-connecting-table"]);
$cols = $table_description["columns"];
$sortable = false;
if (isset($cols["position"])) {
    $sortable = true;
}
$entries = array();
// If we have existing data then this item is either pending or has pending changes so we use that data.
if (is_array($field["value"])) {
    foreach ($field["value"] as $oid) {
        $g = sqlfetch(sqlquery("SELECT * FROM `" . $field["options"]["mtm-other-table"] . "` WHERE id = '{$oid}'"));
        if ($g) {
            $entries[$g["id"]] = $g[$field["options"]["mtm-other-descriptor"]];
        }
    }
    // No pending data, let's query the connecting table directly for the entries, but only if this isn't a new entry
} elseif ($bigtree["edit_id"]) {
    if ($sortable) {
        $q = sqlquery("SELECT * FROM `" . $field["options"]["mtm-connecting-table"] . "` WHERE `" . $field["options"]["mtm-my-id"] . "` = '" . $bigtree["edit_id"] . "' ORDER BY `position` DESC");
    } else {
        $q = sqlquery("SELECT * FROM `" . $field["options"]["mtm-connecting-table"] . "` WHERE `" . $field["options"]["mtm-my-id"] . "` = '" . $bigtree["edit_id"] . "'");
    }
    while ($f = sqlfetch($q)) {
        // Get the title from the other table.
        $g = sqlfetch(sqlquery("SELECT * FROM `" . $field["options"]["mtm-other-table"] . "` WHERE id = '" . $f[$field["options"]["mtm-other-id"]] . "'"));
        if ($g) {
            $entries[$g["id"]] = $g[$field["options"]["mtm-other-descriptor"]];
        }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:many-to-many.php


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