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


PHP PMA_DBI_get_columns函数代码示例

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


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

示例1: PMA_tbl_getFields

/**
 * Gets all the fields of a table along with their types, collations
 * and whether null or not.
 *
 * @param string $db    Selected database
 * @param string $table Selected table
 *
 * @return array Array containing the field list, field types, collations
 * and null constraint
 */
function PMA_tbl_getFields($db, $table)
{
    // Gets the list and number of fields
    $fields = PMA_DBI_get_columns($db, $table, null, true);
    $fields_list = $fields_null = $fields_type = $fields_collation = array();
    $geom_column_present = false;
    $geom_types = PMA_getGISDatatypes();
    foreach ($fields as $key => $row) {
        $fields_list[] = $row['Field'];
        $type = $row['Type'];
        // check whether table contains geometric columns
        if (in_array($type, $geom_types)) {
            $geom_column_present = true;
        }
        // reformat mysql query output
        if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) {
            $type = str_replace(',', ', ', $type);
        } else {
            // strip the "BINARY" attribute, except if we find "BINARY(" because
            // this would be a BINARY or VARBINARY field type
            if (!preg_match('@BINARY[\\(]@i', $type)) {
                $type = preg_replace('@BINARY@i', '', $type);
            }
            $type = preg_replace('@ZEROFILL@i', '', $type);
            $type = preg_replace('@UNSIGNED@i', '', $type);
            $type = strtolower($type);
        }
        if (empty($type)) {
            $type = ' ';
        }
        $fields_null[] = $row['Null'];
        $fields_type[] = $type;
        $fields_collation[] = !empty($row['Collation']) && $row['Collation'] != 'NULL' ? $row['Collation'] : '';
    }
    // end while
    return array($fields_list, $fields_type, $fields_collation, $fields_null, $geom_column_present);
}
开发者ID:tolsasha,项目名称:Forum_PO,代码行数:47,代码来源:tbl_select.lib.php

示例2: array

require_once 'libraries/Index.class.php';
// 2. Gets table keys and retains them
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($table, $db);
$columns_with_unique_index = array();
foreach (PMA_Index::getFromTable($table, $db) as $index) {
    if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
        $columns = $index->getColumns();
        foreach ($columns as $column_name => $dummy) {
            $columns_with_unique_index[$column_name] = 1;
        }
    }
}
unset($index, $columns, $column_name, $dummy);
// 3. Get fields
$fields = (array) PMA_DBI_get_columns($db, $table, null, true);
// Get more complete field information
// For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
// but later, if the analyser returns more information, it
// could be executed for any MySQL version and replace
// the info given by SHOW FULL COLUMNS FROM.
//
// We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
// SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL
// and SHOW CREATE TABLE says NOT NULL (tested
// in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
$show_create_table = PMA_DBI_fetch_value('SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table), 0, 1);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
/**
 * prepare table infos
 */
开发者ID:fanscky,项目名称:HTPMS,代码行数:31,代码来源:tbl_structure.php

示例3: PMA_getSearchSqls

 /**
  * Builds the SQL search query
  *
  * @param string  $table         the table name
  * @param string  $field         restrict the search to this field
  * @param string  $search_str    the string to search
  * @param integer $search_option type of search
  *                               (1 -> 1 word at least, 2 -> all words,
  *                                3 -> exact string, 4 -> regexp)
  *
  * @return array    3 SQL querys (for count, display and delete results)
  *
  * @todo    can we make use of fulltextsearch IN BOOLEAN MODE for this?
  * PMA_backquote
  * PMA_DBI_free_result
  * PMA_DBI_fetch_assoc
  * $GLOBALS['db']
  * explode
  * count
  * strlen
  */
 function PMA_getSearchSqls($table, $field, $search_str, $search_option)
 {
     // Statement types
     $sqlstr_select = 'SELECT';
     $sqlstr_delete = 'DELETE';
     // Fields to select
     $tblfields = PMA_DBI_get_columns($GLOBALS['db'], $table);
     // Table to use
     $sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
     $search_words = $search_option > 2 ? array($search_str) : explode(' ', $search_str);
     $like_or_regex = $search_option == 4 ? 'REGEXP' : 'LIKE';
     $automatic_wildcard = $search_option < 3 ? '%' : '';
     $fieldslikevalues = array();
     foreach ($search_words as $search_word) {
         // Eliminates empty values
         if (strlen($search_word) === 0) {
             continue;
         }
         $thefieldlikevalue = array();
         foreach ($tblfields as $tblfield) {
             if (!isset($field) || strlen($field) == 0 || $tblfield['Field'] == $field) {
                 // Drizzle has no CONVERT and all text columns are UTF-8
                 if (PMA_DRIZZLE) {
                     $thefieldlikevalue[] = PMA_backquote($tblfield['Field']) . ' ' . $like_or_regex . ' ' . "'" . $automatic_wildcard . $search_word . $automatic_wildcard . "'";
                 } else {
                     $thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield['Field']) . ' USING utf8)' . ' ' . $like_or_regex . ' ' . "'" . $automatic_wildcard . $search_word . $automatic_wildcard . "'";
                 }
             }
         }
         // end for
         if (count($thefieldlikevalue) > 0) {
             $fieldslikevalues[] = implode(' OR ', $thefieldlikevalue);
         }
     }
     // end for
     $implode_str = $search_option == 1 ? ' OR ' : ' AND ';
     if (empty($fieldslikevalues)) {
         // this could happen when the "inside field" does not exist
         // in any selected tables
         $sqlstr_where = ' WHERE FALSE';
     } else {
         $sqlstr_where = ' WHERE (' . implode(') ' . $implode_str . ' (', $fieldslikevalues) . ')';
     }
     unset($fieldslikevalues);
     // Builds complete queries
     $sql['select_fields'] = $sqlstr_select . ' * ' . $sqlstr_from . $sqlstr_where;
     // here, I think we need to still use the COUNT clause, even for
     // VIEWs, anyway we have a WHERE clause that should limit results
     $sql['select_count'] = $sqlstr_select . ' COUNT(*) AS `count`' . $sqlstr_from . $sqlstr_where;
     $sql['delete'] = $sqlstr_delete . $sqlstr_from . $sqlstr_where;
     return $sql;
 }
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:73,代码来源:db_search.php

示例4: PMA_getUsernameAndHostnameLength

/**
 * Get username and hostname length
 *
 * @return array username length and hostname length
 */
function PMA_getUsernameAndHostnameLength()
{
    $fields_info = PMA_DBI_get_columns('mysql', 'user', null, true);
    $username_length = 16;
    $hostname_length = 41;
    foreach ($fields_info as $val) {
        if ($val['Field'] == 'User') {
            strtok($val['Type'], '()');
            $value = strtok('()');
            if (is_int($value)) {
                $username_length = $value;
            }
        } elseif ($val['Field'] == 'Host') {
            strtok($val['Type'], '()');
            $value = strtok('()');
            if (is_int($value)) {
                $hostname_length = $value;
            }
        }
    }
    return array($username_length, $hostname_length);
}
开发者ID:SashiAsakura,项目名称:AWS_QuikID_website,代码行数:27,代码来源:server_privileges.lib.php

示例5: PMA_getComments

/**
 * Gets the comments for all rows of a table or the db itself
 *
 * @param string $db    the name of the db to check for
 * @param string $table the name of the table to check for
 *
 * @return  array    [field_name] = comment
 *
 * @access  public
 */
function PMA_getComments($db, $table = '')
{
    $comments = array();
    if ($table != '') {
        // MySQL native column comments
        $fields = PMA_DBI_get_columns($db, $table, null, true);
        if ($fields) {
            foreach ($fields as $field) {
                if (!empty($field['Comment'])) {
                    $comments[$field['Field']] = $field['Comment'];
                }
            }
        }
    } else {
        $comments[] = PMA_getDbComment($db);
    }
    return $comments;
}
开发者ID:AmberWish,项目名称:laba_web,代码行数:28,代码来源:relation.lib.php

示例6: getTableDef

 /**
  * Returns $table's CREATE definition
  *
  * @param string $db            the database name
  * @param string $table         the table name
  * @param string $crlf          the end of line sequence
  * @param string $error_url     the url to go back in case of error
  * @param bool   $do_relation   whether to include relation comments
  * @param bool   $do_comments   whether to include the pmadb-style column
  *                                comments as comments in the structure;
  *                                this is deprecated but the parameter is
  *                                left here because export.php calls
  *                                PMA_exportStructure() also for other
  *                                export types which use this parameter
  * @param bool   $do_mime       whether to include mime comments
  * @param bool   $show_dates    whether to include creation/update/check dates
  * @param bool   $add_semicolon whether to add semicolon and end-of-line
  *                                at the end
  * @param bool   $view          whether we're handling a view
  *
  * @return string resulting schema
  */
 public function getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $show_dates = false, $add_semicolon = true, $view = false)
 {
     // set $cfgRelation here, because there is a chance that it's modified
     // since the class initialization
     global $cfgRelation;
     $schema_insert = '';
     /**
      * Gets fields properties
      */
     PMA_DBI_select_db($db);
     // Check if we can use Relations
     if ($do_relation && !empty($cfgRelation['relation'])) {
         // Find which tables are related with the current one and write it in
         // an array
         $res_rel = PMA_getForeigners($db, $table);
         if ($res_rel && count($res_rel) > 0) {
             $have_rel = true;
         } else {
             $have_rel = false;
         }
     } else {
         $have_rel = false;
     }
     // end if
     /**
      * Displays the table structure
      */
     $schema_insert .= '<table class="width100" cellspacing="1">';
     $columns_cnt = 4;
     if ($do_relation && $have_rel) {
         $columns_cnt++;
     }
     if ($do_comments && $cfgRelation['commwork']) {
         $columns_cnt++;
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $columns_cnt++;
     }
     $schema_insert .= '<tr class="print-category">';
     $schema_insert .= '<th class="print">' . __('Column') . '</th>';
     $schema_insert .= '<td class="print"><strong>' . __('Type') . '</strong></td>';
     $schema_insert .= '<td class="print"><strong>' . __('Null') . '</strong></td>';
     $schema_insert .= '<td class="print"><strong>' . __('Default') . '</strong></td>';
     if ($do_relation && $have_rel) {
         $schema_insert .= '<td class="print"><strong>' . __('Links to') . '</strong></td>';
     }
     if ($do_comments) {
         $schema_insert .= '<td class="print"><strong>' . __('Comments') . '</strong></td>';
         $comments = PMA_getComments($db, $table);
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $schema_insert .= '<td class="print"><strong>' . htmlspecialchars('MIME') . '</strong></td>';
         $mime_map = PMA_getMIME($db, $table, true);
     }
     $schema_insert .= '</tr>';
     $columns = PMA_DBI_get_columns($db, $table);
     /**
      * Get the unique keys in the table
      */
     $unique_keys = array();
     $keys = PMA_DBI_get_table_indexes($db, $table);
     foreach ($keys as $key) {
         if ($key['Non_unique'] == 0) {
             $unique_keys[] = $key['Column_name'];
         }
     }
     foreach ($columns as $column) {
         $schema_insert .= $this->formatOneColumnDefinition($column, $unique_keys);
         $field_name = $column['Field'];
         if ($do_relation && $have_rel) {
             $schema_insert .= '<td class="print">' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '') . '</td>';
         }
         if ($do_comments && $cfgRelation['commwork']) {
             $schema_insert .= '<td class="print">' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '') . '</td>';
         }
         if ($do_mime && $cfgRelation['mimework']) {
             $schema_insert .= '<td class="print">' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '') . '</td>';
         }
//.........这里部分代码省略.........
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:101,代码来源:ExportHtmlword.class.php

示例7: PMA_exportStructure


//.........这里部分代码省略.........
     // end if
     /**
      * Displays the table structure
      */
     $buffer = $crlf . '%' . $crlf . '% ' . __('Structure') . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{';
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     $columns_cnt = 4;
     $alignment = '|l|c|c|c|';
     if ($do_relation && $have_rel) {
         $columns_cnt++;
         $alignment .= 'l|';
     }
     if ($do_comments) {
         $columns_cnt++;
         $alignment .= 'l|';
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $columns_cnt++;
         $alignment .= 'l|';
     }
     $buffer = $alignment . '} ' . $crlf;
     $header = ' \\hline ';
     $header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Type') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Null') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Default') . '}}';
     if ($do_relation && $have_rel) {
         $header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Links to') . '}}';
     }
     if ($do_comments) {
         $header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
         $comments = PMA_getComments($db, $table);
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
         $mime_map = PMA_getMIME($db, $table, true);
     }
     // Table caption for first page and label
     if (isset($GLOBALS['latex_caption'])) {
         $buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\label{' . PMA_expandUserString($GLOBALS['latex_structure_label'], null, array('table' => $table, 'database' => $db)) . '} \\\\' . $crlf;
     }
     $buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
     // Table caption on next pages
     if (isset($GLOBALS['latex_caption'])) {
         $buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_structure_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\\\ ' . $crlf;
     }
     $buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     $fields = PMA_DBI_get_columns($db, $table);
     foreach ($fields as $row) {
         $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
         $type = $extracted_fieldspec['print_type'];
         if (empty($type)) {
             $type = ' ';
         }
         if (!isset($row['Default'])) {
             if ($row['Null'] != 'NO') {
                 $row['Default'] = 'NULL';
             }
         }
         $field_name = $row['Field'];
         $local_buffer = $field_name . "" . $type . "" . ($row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes')) . "" . (isset($row['Default']) ? $row['Default'] : '');
         if ($do_relation && $have_rel) {
             $local_buffer .= "";
             if (isset($res_rel[$field_name])) {
                 $local_buffer .= $res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')';
             }
         }
         if ($do_comments && $cfgRelation['commwork']) {
             $local_buffer .= "";
             if (isset($comments[$field_name])) {
                 $local_buffer .= $comments[$field_name];
             }
         }
         if ($do_mime && $cfgRelation['mimework']) {
             $local_buffer .= "";
             if (isset($mime_map[$field_name])) {
                 $local_buffer .= str_replace('_', '/', $mime_map[$field_name]['mimetype']);
             }
         }
         $local_buffer = PMA_texEscape($local_buffer);
         if ($row['Key'] == 'PRI') {
             $pos = strpos($local_buffer, "");
             $local_buffer = '\\textit{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
         }
         if (in_array($field_name, $unique_keys)) {
             $pos = strpos($local_buffer, "");
             $local_buffer = '\\textbf{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
         }
         $buffer = str_replace("", ' & ', $local_buffer);
         $buffer .= ' \\\\ \\hline ' . $crlf;
         if (!PMA_exportOutputHandler($buffer)) {
             return false;
         }
     }
     // end while
     $buffer = ' \\end{longtable}' . $crlf;
     return PMA_exportOutputHandler($buffer);
 }
开发者ID:ljhchshm,项目名称:weixin,代码行数:101,代码来源:latex.php

示例8: PMA_exportStructure

 /**
  * Outputs table's structure
  *
  * @param string  $db           database name
  * @param string  $table        table name
  * @param string  $crlf         the end of line sequence
  * @param string  $error_url    the url to go back in case of error
  * @param bool    $do_relation  whether to include relation comments
  * @param bool    $do_comments  whether to include the pmadb-style column comments
  *                                as comments in the structure; this is deprecated
  *                                but the parameter is left here because export.php
  *                                calls PMA_exportStructure() also for other export
  *                                types which use this parameter
  * @param bool    $do_mime      whether to include mime comments
  * @param bool    $dates        whether to include creation/update/check dates
  * @param string  $export_mode  'create_table', 'triggers', 'create_view', 'stand_in'
  * @param string  $export_type  'server', 'database', 'table'
  * @return  bool      Whether it succeeded
  *
  * @access  public
  */
 function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
 {
     global $cfgRelation;
     if (!PMA_exportOutputHandler('<h2>' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</h2>')) {
         return false;
     }
     /**
      * Get the unique keys in the table
      */
     $unique_keys = array();
     $keys = PMA_DBI_get_table_indexes($db, $table);
     foreach ($keys as $key) {
         if ($key['Non_unique'] == 0) {
             $unique_keys[] = $key['Column_name'];
         }
     }
     /**
      * Gets fields properties
      */
     PMA_DBI_select_db($db);
     // Check if we can use Relations
     if ($do_relation && !empty($cfgRelation['relation'])) {
         // Find which tables are related with the current one and write it in
         // an array
         $res_rel = PMA_getForeigners($db, $table);
         if ($res_rel && count($res_rel) > 0) {
             $have_rel = true;
         } else {
             $have_rel = false;
         }
     } else {
         $have_rel = false;
     }
     // end if
     /**
      * Displays the table structure
      */
     if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
         return false;
     }
     $columns_cnt = 4;
     if ($do_relation && $have_rel) {
         $columns_cnt++;
     }
     if ($do_comments && $cfgRelation['commwork']) {
         $columns_cnt++;
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $columns_cnt++;
     }
     $schema_insert = '<tr class="print-category">';
     $schema_insert .= '<th class="print">' . __('Column') . '</th>';
     $schema_insert .= '<td class="print"><b>' . __('Type') . '</b></td>';
     $schema_insert .= '<td class="print"><b>' . __('Null') . '</b></td>';
     $schema_insert .= '<td class="print"><b>' . __('Default') . '</b></td>';
     if ($do_relation && $have_rel) {
         $schema_insert .= '<td class="print"><b>' . __('Links to') . '</b></td>';
     }
     if ($do_comments) {
         $schema_insert .= '<td class="print"><b>' . __('Comments') . '</b></td>';
         $comments = PMA_getComments($db, $table);
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $schema_insert .= '<td class="print"><b>' . htmlspecialchars('MIME') . '</b></td>';
         $mime_map = PMA_getMIME($db, $table, true);
     }
     $schema_insert .= '</tr>';
     if (!PMA_exportOutputHandler($schema_insert)) {
         return false;
     }
     $columns = PMA_DBI_get_columns($db, $table);
     foreach ($columns as $column) {
         $schema_insert = '<tr class="print-category">';
         $extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
         $type = htmlspecialchars($extracted_fieldspec['print_type']);
         if (empty($type)) {
             $type = '&nbsp;';
         }
         if (!isset($column['Default'])) {
//.........这里部分代码省略.........
开发者ID:AmberWish,项目名称:laba_web,代码行数:101,代码来源:htmlword.php

示例9: _displayScratchboardTables

 /**
  * Check if there are tables that need to be deleted in dashboard,
  * if there are, ask the user for allowance
  *
  * @param array $array_sh_page array of tables on page
  *
  * @return void
  * @access private
  */
 private function _displayScratchboardTables($array_sh_page)
 {
     global $with_field_names, $db;
     echo '<form method="post" action="schema_edit.php" name="dragdrop">';
     echo '<input type="button" name="dragdrop" id="toggle-dragdrop" ' . 'value="' . __('Toggle scratchboard') . '" />';
     echo '<input type="button" name="dragdropreset" id="reset-dragdrop" ' . 'value="' . __('Reset') . '" />';
     echo '</form>';
     echo '<div id="pdflayout" class="pdflayout" style="visibility: hidden;">';
     $i = 0;
     foreach ($array_sh_page as $temp_sh_page) {
         $drag_x = $temp_sh_page['x'];
         $drag_y = $temp_sh_page['y'];
         echo '<div id="table_' . $i . '" ' . 'data-number="' . $i . '" ' . 'data-x="' . $drag_x . '" ' . 'data-y="' . $drag_y . '" ' . 'class="pdflayout_table"' . '>' . '<u>' . htmlspecialchars($temp_sh_page['table_name']) . '</u>';
         if (isset($with_field_names)) {
             $fields = PMA_DBI_get_columns($db, $temp_sh_page['table_name']);
             // if the table has been dropped from outside phpMyAdmin,
             // we can no longer obtain its columns list
             if ($fields) {
                 foreach ($fields as $row) {
                     echo '<br />' . htmlspecialchars($row['Field']) . "\n";
                 }
             }
         }
         echo '</div>' . "\n";
         $i++;
     }
     echo '</div>';
 }
开发者ID:mindfeederllc,项目名称:openemr,代码行数:37,代码来源:User_Schema.class.php

示例10: _loadTableInfo

 /**
  * Gets all the columns of a table along with their types, collations
  * and whether null or not.
  *
  * @return void
  */
 private function _loadTableInfo()
 {
     // Gets the list and number of columns
     $columns = PMA_DBI_get_columns($this->_db, $this->_table, null, true);
     // Get details about the geometry fucntions
     $geom_types = PMA_Util::getGISDatatypes();
     foreach ($columns as $row) {
         // set column name
         $this->_columnNames[] = $row['Field'];
         $type = $row['Type'];
         // check whether table contains geometric columns
         if (in_array($type, $geom_types)) {
             $this->_geomColumnFlag = true;
         }
         // reformat mysql query output
         if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) {
             $type = str_replace(',', ', ', $type);
         } else {
             // strip the "BINARY" attribute, except if we find "BINARY(" because
             // this would be a BINARY or VARBINARY column type
             if (!preg_match('@BINARY[\\(]@i', $type)) {
                 $type = preg_replace('@BINARY@i', '', $type);
             }
             $type = preg_replace('@ZEROFILL@i', '', $type);
             $type = preg_replace('@UNSIGNED@i', '', $type);
             $type = strtolower($type);
         }
         if (empty($type)) {
             $type = '&nbsp;';
         }
         $this->_columnTypes[] = $type;
         $this->_columnNullFlags[] = $row['Null'];
         $this->_columnCollations[] = !empty($row['Collation']) && $row['Collation'] != 'NULL' ? $row['Collation'] : '';
     }
     // end for
     // Retrieve foreign keys
     $this->_foreigners = PMA_getForeigners($this->_db, $this->_table);
 }
开发者ID:kirstynoble,项目名称:mCrabbTeachingMaterials,代码行数:44,代码来源:TableSearch.class.php

示例11: expandUserString

 /**
  * Formats user string, expanding @VARIABLES@, accepting strftime format
  * string.
  *
  * @param string   $string  Text where to do expansion.
  * @param function $escape  Function to call for escaping variable values.
  *                          Can also be an array of:
  *                          - the escape method name
  *                          - the class that contains the method
  *                          - location of the class (for inclusion)
  * @param array    $updates Array with overrides for default parameters
  *                 (obtained from GLOBALS).
  *
  * @return string
  */
 public static function expandUserString($string, $escape = null, $updates = array())
 {
     /* Content */
     $vars['http_host'] = PMA_getenv('HTTP_HOST');
     $vars['server_name'] = $GLOBALS['cfg']['Server']['host'];
     $vars['server_verbose'] = $GLOBALS['cfg']['Server']['verbose'];
     if (empty($GLOBALS['cfg']['Server']['verbose'])) {
         $vars['server_verbose_or_name'] = $GLOBALS['cfg']['Server']['host'];
     } else {
         $vars['server_verbose_or_name'] = $GLOBALS['cfg']['Server']['verbose'];
     }
     $vars['database'] = $GLOBALS['db'];
     $vars['table'] = $GLOBALS['table'];
     $vars['phpmyadmin_version'] = 'phpMyAdmin ' . PMA_VERSION;
     /* Update forced variables */
     foreach ($updates as $key => $val) {
         $vars[$key] = $val;
     }
     /* Replacement mapping */
     /*
      * The __VAR__ ones are for backward compatibility, because user
      * might still have it in cookies.
      */
     $replace = array('@HTTP_HOST@' => $vars['http_host'], '@SERVER@' => $vars['server_name'], '__SERVER__' => $vars['server_name'], '@VERBOSE@' => $vars['server_verbose'], '@VSERVER@' => $vars['server_verbose_or_name'], '@DATABASE@' => $vars['database'], '__DB__' => $vars['database'], '@TABLE@' => $vars['table'], '__TABLE__' => $vars['table'], '@PHPMYADMIN@' => $vars['phpmyadmin_version']);
     /* Optional escaping */
     if (!is_null($escape)) {
         if (is_array($escape)) {
             include_once $escape[2];
             $escape_class = new $escape[1]();
             $escape_method = $escape[0];
         }
         foreach ($replace as $key => $val) {
             if (is_array($escape)) {
                 $replace[$key] = $escape_class->{$escape_method}($val);
             } else {
                 $replace[$key] = $escape == 'backquote' ? self::$escape($val) : $escape($val);
             }
         }
     }
     /* Backward compatibility in 3.5.x */
     if (strpos($string, '@FIELDS@') !== false) {
         $string = strtr($string, array('@FIELDS@' => '@COLUMNS@'));
     }
     /* Fetch columns list if required */
     if (strpos($string, '@COLUMNS@') !== false) {
         $columns_list = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']);
         // sometimes the table no longer exists at this point
         if (!is_null($columns_list)) {
             $column_names = array();
             foreach ($columns_list as $column) {
                 if (!is_null($escape)) {
                     $column_names[] = self::$escape($column['Field']);
                 } else {
                     $column_names[] = $column['Field'];
                 }
             }
             $replace['@COLUMNS@'] = implode(',', $column_names);
         } else {
             $replace['@COLUMNS@'] = '*';
         }
     }
     /* Do the replacement */
     return strtr(strftime($string), $replace);
 }
开发者ID:niitsken,项目名称:project,代码行数:79,代码来源:Util.class.php

示例12: _getWhereClause

 /**
  * Provides where clause for bulding SQL query
  *
  * @param string $table The table name
  *
  * @return string The generated where clause
  */
 private function _getWhereClause($table)
 {
     $where_clause = '';
     // Columns to select
     $allColumns = PMA_DBI_get_columns($GLOBALS['db'], $table);
     $likeClauses = array();
     // Based on search type, decide like/regex & '%'/''
     $like_or_regex = $this->_criteriaSearchType == 4 ? 'REGEXP' : 'LIKE';
     $automatic_wildcard = $this->_criteriaSearchType < 3 ? '%' : '';
     // For "as regular expression" (search option 4), LIKE won't be used
     // Usage example: If user is seaching for a literal $ in a regexp search,
     // he should enter \$ as the value.
     $this->_criteriaSearchString = PMA_Util::sqlAddSlashes($this->_criteriaSearchString, $this->_criteriaSearchType == 4 ? false : true);
     // Extract search words or pattern
     $search_words = $this->_criteriaSearchType > 2 ? array($this->_criteriaSearchString) : explode(' ', $this->_criteriaSearchString);
     foreach ($search_words as $search_word) {
         // Eliminates empty values
         if (strlen($search_word) === 0) {
             continue;
         }
         $likeClausesPerColumn = array();
         // for each column in the table
         foreach ($allColumns as $column) {
             if (!isset($this->_criteriaColumnName) || strlen($this->_criteriaColumnName) == 0 || $column['Field'] == $this->_criteriaColumnName) {
                 // Drizzle has no CONVERT and all text columns are UTF-8
                 $column = PMA_DRIZZLE ? PMA_Util::backquote($column['Field']) : 'CONVERT(' . PMA_Util::backquote($column['Field']) . ' USING utf8)';
                 $likeClausesPerColumn[] = $column . ' ' . $like_or_regex . ' ' . "'" . $automatic_wildcard . $search_word . $automatic_wildcard . "'";
             }
         }
         // end for
         if (count($likeClausesPerColumn) > 0) {
             $likeClauses[] = implode(' OR ', $likeClausesPerColumn);
         }
     }
     // end for
     // Use 'OR' if 'at least one word' is to be searched, else use 'AND'
     $implode_str = $this->_criteriaSearchType == 1 ? ' OR ' : ' AND ';
     if (empty($likeClauses)) {
         // this could happen when the "inside column" does not exist
         // in any selected tables
         $where_clause = ' WHERE FALSE';
     } else {
         $where_clause = ' WHERE (' . implode(') ' . $implode_str . ' (', $likeClauses) . ')';
     }
     return $where_clause;
 }
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:53,代码来源:DbSearch.class.php

示例13: PMA_displayHtmlForColumnChange

/**
 * Displays HTML for changing one or more columns
 *
 * @param string  $db                       database name
 * @param string  $table                    table name
 * @param array   $selected                 the selected columns
 * @param string  $action                   target script to call 
 *
 * @return boolean $regenerate              true if error occurred
 * 
 */
function PMA_displayHtmlForColumnChange($db, $table, $selected, $action)
{
    // $selected comes from multi_submits.inc.php
    if (empty($selected)) {
        $selected[] = $_REQUEST['field'];
        $selected_cnt = 1;
    } else {
        // from a multiple submit
        $selected_cnt = count($selected);
    }
    /**
     * @todo optimize in case of multiple fields to modify
     */
    for ($i = 0; $i < $selected_cnt; $i++) {
        $fields_meta[] = PMA_DBI_get_columns($db, $table, $selected[$i], true);
    }
    $num_fields = count($fields_meta);
    // set these globals because tbl_columns_definition_form.inc.php
    // verifies them
    // @todo: refactor tbl_columns_definition_form.inc.php so that it uses
    // function params
    $GLOBALS['action'] = 'tbl_structure.php';
    $GLOBALS['num_fields'] = $num_fields;
    // Get more complete field information.
    // For now, this is done to obtain MySQL 4.1.2+ new TIMESTAMP options
    // and to know when there is an empty DEFAULT value.
    // Later, if the analyser returns more information, it
    // could be executed to replace the info given by SHOW FULL COLUMNS FROM.
    /**
     * @todo put this code into a require()
     * or maybe make it part of PMA_DBI_get_columns();
     */
    // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
    // SHOW FULL COLUMNS says NULL and SHOW CREATE TABLE says NOT NULL (tested
    // in MySQL 4.0.25).
    $show_create_table = PMA_DBI_fetch_value('SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table), 0, 1);
    $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
    unset($show_create_table);
    /**
     * Form for changing properties.
     */
    include 'libraries/tbl_columns_definition_form.inc.php';
}
开发者ID:mindfeederllc,项目名称:openemr,代码行数:54,代码来源:structure.lib.php

示例14: PMA_showMessage

        $disp_query = null;
    }
    PMA_showMessage($disp_message, $disp_query);
}
/**
 * Get the analysis of SHOW CREATE TABLE for this table
 * @todo should be handled by class Table
 */
$show_create_table = PMA_DBI_fetch_value('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0, 1);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
unset($show_create_table);
/**
 * Get the list of the fields of the current table
 */
PMA_DBI_select_db($db);
$table_fields = array_values(PMA_DBI_get_columns($db, $table));
$rows = array();
if (isset($where_clause)) {
    // when in edit mode load all selected rows from table
    $insert_mode = false;
    if (is_array($where_clause)) {
        $where_clause_array = $where_clause;
    } else {
        $where_clause_array = array(0 => $where_clause);
    }
    $result = array();
    $found_unique_key = false;
    $where_clauses = array();
    foreach ($where_clause_array as $key_id => $where_clause) {
        $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
        $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
开发者ID:rizwanaabbas,项目名称:phpmyadmin,代码行数:31,代码来源:tbl_change.php

示例15: PMA_buildActionTitles

 * Get some core libraries
 */
require_once './libraries/common.inc.php';
$action = 'tbl_create.php';
require_once './libraries/header.inc.php';
$titles = PMA_buildActionTitles();
// Check parameters
PMA_checkParameters(array('db'));
/* Check if database name is empty */
if (strlen($db) == 0) {
    PMA_mysqlDie(__('The database name is empty!'), '', '', 'main.php');
}
/**
 * Defines the url to return to in case of error in a sql statement
 */
if (PMA_DBI_get_columns($db, $table)) {
    // table exists already
    PMA_mysqlDie(sprintf(__('Table %s already exists!'), htmlspecialchars($table)), '', '', 'db_structure.php?' . PMA_generate_common_url($db));
}
$err_url = 'tbl_create.php?' . PMA_generate_common_url($db, $table);
// check number of fields to be created
if (isset($_REQUEST['submit_num_fields'])) {
    $regenerate = true;
    // for libraries/tbl_properties.inc.php
    $num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
    $num_fields = (int) $_REQUEST['num_fields'];
} else {
    $num_fields = 2;
}
/**
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:31,代码来源:tbl_create.php


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