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


PHP indexes函数代码示例

本文整理汇总了PHP中indexes函数的典型用法代码示例。如果您正苦于以下问题:PHP indexes函数的具体用法?PHP indexes怎么用?PHP indexes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: array

<?php

$TABLE = $_GET["indexes"];
$index_types = array("PRIMARY", "UNIQUE", "INDEX");
$table_status = table_status($TABLE, true);
if (preg_match('~MyISAM|M?aria' . ($connection->server_info >= 5.6 ? '|InnoDB' : '') . '~i', $table_status["Engine"])) {
    $index_types[] = "FULLTEXT";
}
$indexes = indexes($TABLE);
$primary = array();
if ($jush == "mongo") {
    // doesn't support primary key
    $primary = $indexes["_id_"];
    unset($index_types[0]);
    unset($indexes["_id_"]);
}
$row = $_POST;
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
    $alter = array();
    foreach ($row["indexes"] as $index) {
        $name = $index["name"];
        if (in_array($index["type"], $index_types)) {
            $columns = array();
            $lengths = array();
            $descs = array();
            $set = array();
            ksort($index["columns"]);
            foreach ($index["columns"] as $key => $column) {
                if ($column != "") {
                    $length = $index["lengths"][$key];
                    $desc = $index["descs"][$key];
开发者ID:unix4you2,项目名称:pmydb,代码行数:31,代码来源:indexes.inc.php

示例2: select

function select($result)
{
    global $SELF;
    if (!$result->num_rows) {
        echo "<p class='message'>" . lang('No rows.') . "</p>\n";
    } else {
        echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
        for ($i = 0; $row = $result->fetch_row(); $i++) {
            if (!$i) {
                echo "<thead><tr>";
                $links = array();
                $indexes = array();
                $columns = array();
                $blobs = array();
                $types = array();
                for ($j = 0; $j < count($row); $j++) {
                    $field = $result->fetch_field();
                    if (strlen($field->orgtable)) {
                        if (!isset($indexes[$field->orgtable])) {
                            $indexes[$field->orgtable] = array();
                            foreach (indexes($field->orgtable) as $index) {
                                if ($index["type"] == "PRIMARY") {
                                    $indexes[$field->orgtable] = array_flip($index["columns"]);
                                    break;
                                }
                            }
                            $columns[$field->orgtable] = $indexes[$field->orgtable];
                        }
                        if (isset($columns[$field->orgtable][$field->orgname])) {
                            unset($columns[$field->orgtable][$field->orgname]);
                            $indexes[$field->orgtable][$field->orgname] = $j;
                            $links[$j] = $field->orgtable;
                        }
                    }
                    if ($field->charsetnr == 63) {
                        $blobs[$j] = true;
                    }
                    $types[$j] = $field->type;
                    echo "<th>" . htmlspecialchars($field->name) . "</th>";
                }
                echo "</tr></thead>\n";
            }
            echo "<tr>";
            foreach ($row as $key => $val) {
                if (!isset($val)) {
                    $val = "<i>NULL</i>";
                } else {
                    if ($blobs[$key] && preg_match('~[\\x80-\\xFF]~', $val)) {
                        $val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>";
                    } else {
                        $val = strlen(trim($val)) ? nl2br(htmlspecialchars($val)) : "&nbsp;";
                        if ($types[$key] == 254) {
                            $val = "<code>{$val}</code>";
                        }
                    }
                    if (isset($links[$key]) && !$columns[$links[$key]]) {
                        $link = "edit=" . urlencode($links[$key]);
                        foreach ($indexes[$links[$key]] as $col => $j) {
                            $link .= "&amp;where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
                        }
                        $val = '<a href="' . htmlspecialchars($SELF) . $link . '">' . $val . '</a>';
                    }
                }
                echo "<td>{$val}</td>";
            }
            echo "</tr>\n";
        }
        echo "</table>\n";
    }
    $result->free();
}
开发者ID:rohdoor,项目名称:ehcp,代码行数:71,代码来源:phpadmin.php

示例3: select

/** Print select result
* @param Min_Result
* @param Min_DB connection to examine indexes
* @param array
* @param int
* @return array $orgtables
*/
function select($result, $connection2 = null, $orgtables = array(), $limit = 0)
{
    global $jush;
    $links = array();
    // colno => orgtable - create links from these columns
    $indexes = array();
    // orgtable => array(column => colno) - primary keys
    $columns = array();
    // orgtable => array(column => ) - not selected columns in primary key
    $blobs = array();
    // colno => bool - display bytes for blobs
    $types = array();
    // colno => type - display char in <code>
    $return = array();
    // table => orgtable - mapping to use in EXPLAIN
    odd('');
    // reset odd for each result
    for ($i = 0; (!$limit || $i < $limit) && ($row = $result->fetch_row()); $i++) {
        if (!$i) {
            echo "<table cellspacing='0' class='nowrap'>\n";
            echo "<thead><tr>";
            for ($j = 0; $j < count($row); $j++) {
                $field = $result->fetch_field();
                $name = $field->name;
                $orgtable = $field->orgtable;
                $orgname = $field->orgname;
                $return[$field->table] = $orgtable;
                if ($orgtables && $jush == "sql") {
                    // MySQL EXPLAIN
                    $links[$j] = $name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null);
                } elseif ($orgtable != "") {
                    if (!isset($indexes[$orgtable])) {
                        // find primary key in each table
                        $indexes[$orgtable] = array();
                        foreach (indexes($orgtable, $connection2) as $index) {
                            if ($index["type"] == "PRIMARY") {
                                $indexes[$orgtable] = array_flip($index["columns"]);
                                break;
                            }
                        }
                        $columns[$orgtable] = $indexes[$orgtable];
                    }
                    if (isset($columns[$orgtable][$orgname])) {
                        unset($columns[$orgtable][$orgname]);
                        $indexes[$orgtable][$orgname] = $j;
                        $links[$j] = $orgtable;
                    }
                }
                if ($field->charsetnr == 63) {
                    // 63 - binary
                    $blobs[$j] = true;
                }
                $types[$j] = $field->type;
                echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "{$orgtable}." : "") . $orgname) . "'" : "") . ">" . h($name) . ($orgtables ? doc_link(array('sql' => "explain-output.html#explain_" . strtolower($name))) : "");
            }
            echo "</thead>\n";
        }
        echo "<tr" . odd() . ">";
        foreach ($row as $key => $val) {
            if ($val === null) {
                $val = "<i>NULL</i>";
            } elseif ($blobs[$key] && !is_utf8($val)) {
                $val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>";
                //! link to download
            } elseif (!strlen($val)) {
                // strlen - SQLite can return int
                $val = "&nbsp;";
                // some content to print a border
            } else {
                $val = h($val);
                if ($types[$key] == 254) {
                    // 254 - char
                    $val = "<code>{$val}</code>";
                }
            }
            if (isset($links[$key]) && !$columns[$links[$key]]) {
                if ($orgtables && $jush == "sql") {
                    // MySQL EXPLAIN
                    $table = $row[array_search("table=", $links)];
                    $link = $links[$key] . urlencode($orgtables[$table] != "" ? $orgtables[$table] : $table);
                } else {
                    $link = "edit=" . urlencode($links[$key]);
                    foreach ($indexes[$links[$key]] as $col => $j) {
                        $link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
                    }
                }
                $val = "<a href='" . h(ME . $link) . "'>{$val}</a>";
            }
            echo "<td>{$val}";
        }
    }
    echo ($i ? "</table>" : "<p class='message'>" . lang('No rows.')) . "\n";
    return $return;
//.........这里部分代码省略.........
开发者ID:ly95,项目名称:adminer,代码行数:101,代码来源:editing.inc.php

示例4: auto_increment

 /** Generate modifier for auto increment column
  * @return string
  */
 function auto_increment()
 {
     $auto_increment_index = " PRIMARY KEY";
     // don't overwrite primary key by auto_increment
     if ($_GET["create"] != "" && $_POST["auto_increment_col"]) {
         foreach (indexes($_GET["create"]) as $index) {
             if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
                 $auto_increment_index = "";
                 break;
             }
             if ($index["type"] == "PRIMARY") {
                 $auto_increment_index = " UNIQUE";
             }
         }
     }
     return " AUTO_INCREMENT{$auto_increment_index}";
 }
开发者ID:tomec-martin,项目名称:adminer,代码行数:20,代码来源:mysqlssl.inc.php


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