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


PHP Util::backquote方法代码示例

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


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

示例1: 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 string $export_mode 'create_table','triggers','create_view',
  *                            'stand_in'
  * @param string $export_type 'server', 'database', 'table'
  * @param bool   $relation    whether to include relation comments
  * @param bool   $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 exportStructure()
  *                            also for other export types which use this
  *                            parameter
  * @param bool   $mime        whether to include mime comments
  * @param bool   $dates       whether to include creation/update/check dates
  * @param array  $aliases     Aliases of db/table/columns
  *
  * @return bool Whether it succeeded
  */
 public function exportStructure($db, $table, $crlf, $error_url, $export_mode, $export_type, $relation = false, $comments = false, $mime = false, $dates = false, $aliases = array())
 {
     $db_alias = $db;
     $table_alias = $table;
     $this->initAlias($aliases, $db_alias, $table_alias);
     if (isset($GLOBALS['sql_compatibility'])) {
         $compat = $GLOBALS['sql_compatibility'];
     } else {
         $compat = 'NONE';
     }
     $formatted_table_name = Util::backquoteCompat($table_alias, $compat, isset($GLOBALS['sql_backquotes']));
     $dump = $this->_possibleCRLF() . $this->_exportComment(str_repeat('-', 56)) . $this->_possibleCRLF() . $this->_exportComment();
     switch ($export_mode) {
         case 'create_table':
             $dump .= $this->_exportComment(__('Table structure for table') . ' ' . $formatted_table_name);
             $dump .= $this->_exportComment();
             $dump .= $this->getTableDef($db, $table, $crlf, $error_url, $dates, true, false, true, $aliases);
             $dump .= $this->_getTableComments($db, $table, $crlf, $relation, $mime, $aliases);
             break;
         case 'triggers':
             $dump = '';
             $delimiter = '$$';
             $triggers = $GLOBALS['dbi']->getTriggers($db, $table, $delimiter);
             if ($triggers) {
                 $dump .= $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('Triggers') . ' ' . $formatted_table_name) . $this->_exportComment();
                 $used_alias = false;
                 $trigger_query = '';
                 foreach ($triggers as $trigger) {
                     if (!empty($GLOBALS['sql_drop_table'])) {
                         $trigger_query .= $trigger['drop'] . ';' . $crlf;
                     }
                     $trigger_query .= 'DELIMITER ' . $delimiter . $crlf;
                     $trigger_query .= $this->replaceWithAliases($trigger['create'], $aliases, $db, $table, $flag);
                     if ($flag) {
                         $used_alias = true;
                     }
                     $trigger_query .= 'DELIMITER ;' . $crlf;
                 }
                 // One warning per table.
                 if ($used_alias) {
                     $dump .= $this->_exportComment(__('It appears your table uses triggers;')) . $this->_exportComment(__('alias export may not work reliably in all cases.')) . $this->_exportComment();
                 }
                 $dump .= $trigger_query;
             }
             break;
         case 'create_view':
             if (empty($GLOBALS['sql_views_as_tables'])) {
                 $dump .= $this->_exportComment(__('Structure for view') . ' ' . $formatted_table_name) . $this->_exportComment();
                 // delete the stand-in table previously created (if any)
                 if ($export_type != 'table') {
                     $dump .= 'DROP TABLE IF EXISTS ' . Util::backquote($table_alias) . ';' . $crlf;
                 }
                 $dump .= $this->getTableDef($db, $table, $crlf, $error_url, $dates, true, true, true, $aliases);
             } else {
                 $dump .= $this->_exportComment(sprintf(__('Structure for view %s exported as a table'), $formatted_table_name)) . $this->_exportComment();
                 // delete the stand-in table previously created (if any)
                 if ($export_type != 'table') {
                     $dump .= 'DROP TABLE IF EXISTS ' . Util::backquote($table_alias) . ';' . $crlf;
                 }
                 $dump .= $this->_getTableDefForView($db, $table, $crlf, true, $aliases);
             }
             break;
         case 'stand_in':
             $dump .= $this->_exportComment(__('Stand-in structure for view') . ' ' . $formatted_table_name) . $this->_exportComment();
             // export a stand-in definition to resolve view dependencies
             $dump .= $this->getTableDefStandIn($db, $table, $crlf, $aliases);
     }
     // end switch
     // this one is built by getTableDef() to use in table copy/move
     // but not in the case of export
     unset($GLOBALS['sql_constraints_query']);
     return PMA_exportOutputHandler($dump);
 }
开发者ID:ryanfmurphy,项目名称:phpmyadmin,代码行数:96,代码来源:ExportSql.php

示例2: PMA_moveOrCopyTable

/**
 * Move or copy a table
 *
 * @param string $db    current database name
 * @param string $table current table name
 *
 * @return void
 */
function PMA_moveOrCopyTable($db, $table)
{
    /**
     * Selects the database to work with
     */
    $GLOBALS['dbi']->selectDb($db);
    /**
     * $_REQUEST['target_db'] could be empty in case we came from an input field
     * (when there are many databases, no drop-down)
     */
    if (empty($_REQUEST['target_db'])) {
        $_REQUEST['target_db'] = $db;
    }
    /**
     * A target table name has been sent to this script -> do the work
     */
    if (PMA_isValid($_REQUEST['new_name'])) {
        if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
            if (isset($_REQUEST['submit_move'])) {
                $message = Message::error(__('Can\'t move table to same one!'));
            } else {
                $message = Message::error(__('Can\'t copy table to same one!'));
            }
        } else {
            Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
            if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) {
                if (isset($_REQUEST['submit_move'])) {
                    PMA_AdjustPrivileges_renameOrMoveTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
                } else {
                    PMA_AdjustPrivileges_copyTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
                }
                if (isset($_REQUEST['submit_move'])) {
                    $message = Message::success(__('Table %s has been moved to %s. Privileges have been ' . 'adjusted.'));
                } else {
                    $message = Message::success(__('Table %s has been copied to %s. Privileges have been ' . 'adjusted.'));
                }
            } else {
                if (isset($_REQUEST['submit_move'])) {
                    $message = Message::success(__('Table %s has been moved to %s.'));
                } else {
                    $message = Message::success(__('Table %s has been copied to %s.'));
                }
            }
            $old = PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table);
            $message->addParam($old);
            $new = PMA\libraries\Util::backquote($_REQUEST['target_db']) . '.' . PMA\libraries\Util::backquote($_REQUEST['new_name']);
            $message->addParam($new);
            /* Check: Work on new table or on old table? */
            if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
            }
        }
    } else {
        /**
         * No new name for the table!
         */
        $message = Message::error(__('The table name is empty!'));
    }
    if ($GLOBALS['is_ajax_request'] == true) {
        $response = PMA\libraries\Response::getInstance();
        $response->addJSON('message', $message);
        if ($message->isSuccess()) {
            $response->addJSON('db', $GLOBALS['db']);
        } else {
            $response->setRequestStatus(false);
        }
        exit;
    }
}
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:76,代码来源:operations.lib.php

示例3: PMA_RTN_createRoutine

/**
 * Create the routine
 *
 * @param string $routine_query    Query to create routine
 * @param string $create_routine   Query to restore routine
 * @param array  $privilegesBackup Privileges backup
 *
 * @return array
 */
function PMA_RTN_createRoutine($routine_query, $create_routine, $privilegesBackup)
{
    $result = $GLOBALS['dbi']->tryQuery($routine_query);
    if (!$result) {
        $errors = array();
        $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
        // We dropped the old routine,
        // but were unable to create the new one
        // Try to restore the backup query
        $result = $GLOBALS['dbi']->tryQuery($create_routine);
        $errors = checkResult($result, __('Sorry, we failed to restore' . ' the dropped routine.'), $create_routine, $errors);
        return array($errors, null);
    }
    // Default value
    $resultAdjust = false;
    if ($GLOBALS['proc_priv'] && $GLOBALS['is_reload_priv']) {
        // Insert all the previous privileges
        // but with the new name and the new type
        foreach ($privilegesBackup as $priv) {
            $adjustProcPrivilege = 'INSERT INTO ' . Util::backquote('mysql') . '.' . Util::backquote('procs_priv') . ' VALUES("' . $priv[0] . '", "' . $priv[1] . '", "' . $priv[2] . '", "' . $_REQUEST['item_name'] . '", "' . $_REQUEST['item_type'] . '", "' . $priv[5] . '", "' . $priv[6] . '", "' . $priv[7] . '");';
            $resultAdjust = $GLOBALS['dbi']->query($adjustProcPrivilege);
        }
    }
    $message = PMA_RTN_flushPrivileges($resultAdjust);
    return array(array(), $message);
}
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:35,代码来源:rte_routines.lib.php

示例4: displayTableList

 /**
  * Displays the list of tables
  *
  * @return void
  */
 protected function displayTableList()
 {
     // table form
     $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
     $i = $sum_entries = 0;
     $overhead_check = '';
     $create_time_all = '';
     $update_time_all = '';
     $check_time_all = '';
     $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
     $row_count = 0;
     $sum_size = (double) 0;
     $overhead_size = (double) 0;
     $hidden_fields = array();
     $odd_row = true;
     $overall_approx_rows = false;
     foreach ($this->_tables as $keyname => $current_table) {
         // Get valid statistics whatever is the table type
         $drop_query = '';
         $drop_message = '';
         $overhead = '';
         $table_is_view = false;
         $table_encoded = urlencode($current_table['TABLE_NAME']);
         // Sets parameters for links
         $tbl_url_query = $this->_url_query . '&amp;table=' . $table_encoded;
         // do not list the previous table's size info for a view
         list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size);
         $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']);
         if (!$curTable->isMerge()) {
             $sum_entries += $current_table['TABLE_ROWS'];
         }
         if (isset($current_table['Collation'])) {
             $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>';
         } else {
             $collation = '---';
         }
         if ($this->_is_show_stats) {
             if ($formatted_overhead != '') {
                 $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span>&nbsp;' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n";
                 $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');";
             } else {
                 $overhead = '-';
             }
         }
         // end if
         $showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true);
         if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
             $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : '';
             if ($create_time && (!$create_time_all || $create_time < $create_time_all)) {
                 $create_time_all = $create_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : '';
             if ($update_time && (!$update_time_all || $update_time < $update_time_all)) {
                 $update_time_all = $update_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : '';
             if ($check_time && (!$check_time_all || $check_time < $check_time_all)) {
                 $check_time_all = $check_time;
             }
         }
         $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
         $truename = str_replace(' ', '&nbsp;', $truename);
         $i++;
         $row_count++;
         if ($table_is_view) {
             $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
         }
         /*
          * Always activate links for Browse, Search and Empty, even if
          * the icons are greyed, because
          * 1. for views, we don't know the number of rows at this point
          * 2. for tables, another source could have populated them since the
          *    page was generated
          *
          * I could have used the PHP ternary conditional operator but I find
          * the code easier to read without this operator.
          */
         $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view;
         $titles = Util::buildActionTitles();
         $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
         $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
         $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename));
         $empty_table = '';
         if (!$this->_db_is_system_schema) {
             $empty_table = '&nbsp;';
             if (!$table_is_view) {
                 $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty']));
//.........这里部分代码省略.........
开发者ID:netroby,项目名称:phpmyadmin,代码行数:101,代码来源:DatabaseStructureController.php

示例5: getFileName

 /**
  * Returns the file name
  *
  * @param String $extension file extension
  *
  * @return string file name
  */
 protected function getFileName($extension)
 {
     $filename = $this->db . $extension;
     // Get the name of this page to use as filename
     if ($this->pageNumber != -1 && !$this->offline) {
         $_name_sql = 'SELECT page_descr FROM ' . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['pdf_pages']) . ' WHERE page_nr = ' . $this->pageNumber;
         $_name_rs = PMA_queryAsControlUser($_name_sql);
         $_name_row = $GLOBALS['dbi']->fetchRow($_name_rs);
         $filename = $_name_row[0] . $extension;
     }
     return $filename;
 }
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:19,代码来源:ExportRelationSchema.php

示例6: PMA_addUserAndCreateDatabase

/**
 * Prepares queries for adding users and
 * also create database and return query and message
 *
 * @param boolean $_error         whether user create or not
 * @param string  $real_sql_query SQL query for add a user
 * @param string  $sql_query      SQL query to be displayed
 * @param string  $username       username
 * @param string  $hostname       host name
 * @param string  $dbname         database name
 *
 * @return array  $sql_query, $message
 */
function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query, $username, $hostname, $dbname)
{
    if ($_error || !empty($real_sql_query) && !$GLOBALS['dbi']->tryQuery($real_sql_query)) {
        $_REQUEST['createdb-1'] = $_REQUEST['createdb-2'] = $_REQUEST['createdb-3'] = null;
        $message = Message::rawError($GLOBALS['dbi']->getError());
    } else {
        $message = Message::success(__('You have added a new user.'));
    }
    if (isset($_REQUEST['createdb-1'])) {
        // Create database with same name and grant all privileges
        $q = 'CREATE DATABASE IF NOT EXISTS ' . Util::backquote(Util::sqlAddSlashes($username)) . ';';
        $sql_query .= $q;
        if (!$GLOBALS['dbi']->tryQuery($q)) {
            $message = Message::rawError($GLOBALS['dbi']->getError());
        }
        /**
         * Reload the navigation
         */
        $GLOBALS['reload'] = true;
        $GLOBALS['db'] = $username;
        $q = 'GRANT ALL PRIVILEGES ON ' . Util::backquote(Util::escapeMysqlWildcards(Util::sqlAddSlashes($username))) . '.* TO \'' . Util::sqlAddSlashes($username) . '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
        $sql_query .= $q;
        if (!$GLOBALS['dbi']->tryQuery($q)) {
            $message = Message::rawError($GLOBALS['dbi']->getError());
        }
    }
    if (isset($_REQUEST['createdb-2'])) {
        // Grant all privileges on wildcard name (username\_%)
        $q = 'GRANT ALL PRIVILEGES ON ' . Util::backquote(Util::sqlAddSlashes($username) . '\\_%') . '.* TO \'' . Util::sqlAddSlashes($username) . '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
        $sql_query .= $q;
        if (!$GLOBALS['dbi']->tryQuery($q)) {
            $message = Message::rawError($GLOBALS['dbi']->getError());
        }
    }
    if (isset($_REQUEST['createdb-3'])) {
        // Grant all privileges on the specified database to the new user
        $q = 'GRANT ALL PRIVILEGES ON ' . Util::backquote(Util::sqlAddSlashes($dbname)) . '.* TO \'' . Util::sqlAddSlashes($username) . '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
        $sql_query .= $q;
        if (!$GLOBALS['dbi']->tryQuery($q)) {
            $message = Message::rawError($GLOBALS['dbi']->getError());
        }
    }
    return array($sql_query, $message);
}
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:57,代码来源:server_privileges.lib.php

示例7: _getWhereClause

 /**
  * Return the where clause for query generation based on the inputs provided.
  *
  * @param mixed  $criteriaValues Search criteria input
  * @param string $names          Name of the column on which search is submitted
  * @param string $types          Type of the field
  * @param string $func_type      Search function/operator
  * @param bool   $unaryFlag      Whether operator unary or not
  * @param bool   $geom_func      Whether geometry functions should be applied
  *
  * @return string generated where clause.
  */
 private function _getWhereClause($criteriaValues, $names, $types, $func_type, $unaryFlag, $geom_func = null)
 {
     // If geometry function is set
     if (!empty($geom_func)) {
         return $this->_getGeomWhereClause($criteriaValues, $names, $func_type, $types, $geom_func);
     }
     $backquoted_name = Util::backquote($names);
     $where = '';
     if ($unaryFlag) {
         $where = $backquoted_name . ' ' . $func_type;
     } elseif (strncasecmp($types, 'enum', 4) == 0 && !empty($criteriaValues)) {
         $where = $backquoted_name;
         $where .= $this->_getEnumWhereClause($criteriaValues, $func_type);
     } elseif ($criteriaValues != '') {
         // For these types we quote the value. Even if it's another type
         // (like INT), for a LIKE we always quote the value. MySQL converts
         // strings to numbers and numbers to strings as necessary
         // during the comparison
         if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types) || mb_strpos(' ' . $func_type, 'LIKE')) {
             $quot = '\'';
         } else {
             $quot = '';
         }
         // LIKE %...%
         if ($func_type == 'LIKE %...%') {
             $func_type = 'LIKE';
             $criteriaValues = '%' . $criteriaValues . '%';
         }
         if ($func_type == 'REGEXP ^...$') {
             $func_type = 'REGEXP';
             $criteriaValues = '^' . $criteriaValues . '$';
         }
         if ('IN (...)' != $func_type && 'NOT IN (...)' != $func_type && 'BETWEEN' != $func_type && 'NOT BETWEEN' != $func_type) {
             if ($func_type == 'LIKE %...%' || $func_type == 'LIKE') {
                 $where = $backquoted_name . ' ' . $func_type . ' ' . $quot . Util::sqlAddSlashes($criteriaValues, true) . $quot;
             } else {
                 $where = $backquoted_name . ' ' . $func_type . ' ' . $quot . Util::sqlAddSlashes($criteriaValues) . $quot;
             }
             return $where;
         }
         $func_type = str_replace(' (...)', '', $func_type);
         //Don't explode if this is already an array
         //(Case for (NOT) IN/BETWEEN.)
         if (is_array($criteriaValues)) {
             $values = $criteriaValues;
         } else {
             $values = explode(',', $criteriaValues);
         }
         // quote values one by one
         $emptyKey = false;
         foreach ($values as $key => &$value) {
             if ('' === $value) {
                 $emptyKey = $key;
                 $value = 'NULL';
                 continue;
             }
             $value = $quot . Util::sqlAddSlashes(trim($value)) . $quot;
         }
         if ('BETWEEN' == $func_type || 'NOT BETWEEN' == $func_type) {
             $where = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '') . ' AND ' . (isset($values[1]) ? $values[1] : '');
         } else {
             //[NOT] IN
             if (false !== $emptyKey) {
                 unset($values[$emptyKey]);
             }
             $wheres = array();
             if (!empty($values)) {
                 $wheres[] = $backquoted_name . ' ' . $func_type . ' (' . implode(',', $values) . ')';
             }
             if (false !== $emptyKey) {
                 $wheres[] = $backquoted_name . ' IS NULL';
             }
             $where = implode(' OR ', $wheres);
             if (1 < count($wheres)) {
                 $where = '(' . $where . ')';
             }
         }
     }
     // end if
     return $where;
 }
开发者ID:rclakmal,项目名称:phpmyadmin,代码行数:93,代码来源:TableSearchController.php

示例8: getRealRowCountTable

 /**
  * Returns the real row count for a table
  *
  * @return number
  */
 function getRealRowCountTable()
 {
     // SQL query to get row count for a table.
     $result = $this->_dbi->fetchSingleRow(sprintf('SELECT COUNT(*) AS %s FROM %s.%s', Util::backquote('row_count'), Util::backquote($this->_db_name), Util::backquote($this->_name)));
     return $result['row_count'];
 }
开发者ID:ryanfmurphy,项目名称:phpmyadmin,代码行数:11,代码来源:Table.php

示例9: PMA_sendHeaderLocation

        if ($response->isAjax()) {
            $response->setRequestStatus(false);
            $response->addJSON('message', Message::error(__('No databases selected.')));
        } else {
            PMA_sendHeaderLocation($uri);
        }
        exit;
    }
}
// end if (ensures db exists)
/**
 * Changes database charset if requested by the user
 */
if (isset($_REQUEST['submitcollation']) && isset($_REQUEST['db_collation']) && !empty($_REQUEST['db_collation'])) {
    list($db_charset) = explode('_', $_REQUEST['db_collation']);
    $sql_query = 'ALTER DATABASE ' . PMA\libraries\Util::backquote($db) . ' DEFAULT' . Util::getCharsetQueryPart($_REQUEST['db_collation']);
    $result = $GLOBALS['dbi']->query($sql_query);
    $message = Message::success();
    unset($db_charset);
    /**
     * If we are in an Ajax request, let us stop the execution here. Necessary for
     * db charset change action on db_operations.php.  If this causes a bug on
     * other pages, we might have to move this to a different location.
     */
    if ($GLOBALS['is_ajax_request'] == true) {
        $response = PMA\libraries\Response::getInstance();
        $response->setRequestStatus($message->isSuccess());
        $response->addJSON('message', $message);
        exit;
    }
}
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:31,代码来源:db_common.inc.php

示例10: sprintf

             // In such case we can use the value of port.
             $server_details['port'] = $cfg['Server']['port'];
         }
         // otherwise we leave the $server_details['port'] unset,
         // allowing it to take default mysql port
         $controllink = $GLOBALS['dbi']->connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], true, $server_details);
     } else {
         $controllink = $GLOBALS['dbi']->connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], true);
     }
 }
 // Connects to the server (validates user's login)
 /** @var DatabaseInterface $userlink */
 $userlink = $GLOBALS['dbi']->connect($cfg['Server']['user'], $cfg['Server']['password'], false);
 // Set timestamp for the session, if required.
 if ($cfg['Server']['SessionTimeZone'] != '') {
     $sql_query_tz = 'SET ' . Util::backquote('time_zone') . ' = ' . '\'' . Util::sqlAddSlashes($cfg['Server']['SessionTimeZone']) . '\'';
     if (!$userlink->query($sql_query_tz)) {
         $error_message_tz = sprintf(__('Unable to use timezone %1$s for server %2$d. ' . 'Please check your configuration setting for ' . '[em]$cfg[\'Servers\'][%3$d][\'SessionTimeZone\'][/em]. ' . 'phpMyAdmin is currently using the default time zone ' . 'of the database server.'), $cfg['Servers'][$GLOBALS['server']]['SessionTimeZone'], $GLOBALS['server'], $GLOBALS['server']);
         $GLOBALS['error_handler']->addError($error_message_tz, E_USER_WARNING, '', '', false);
     }
 }
 if (!$controllink) {
     $controllink = $userlink;
 }
 $auth_plugin->storeUserCredentials();
 /* Log success */
 PMA_logUser($cfg['Server']['user']);
 if (PMA_MYSQL_INT_VERSION < $cfg['MysqlMinVersion']['internal']) {
     PMA_fatalError(__('You should upgrade to %s %s or later.'), array('MySQL', $cfg['MysqlMinVersion']['human']));
 }
 /**
开发者ID:deerob,项目名称:phpmyadmin,代码行数:31,代码来源:common.inc.php

示例11: getKeyForTablePrimary

 /**
  * Gets table primary key
  *
  * @return string
  */
 protected function getKeyForTablePrimary()
 {
     $this->dbi->selectDb($this->db);
     $result = $this->dbi->query('SHOW KEYS FROM ' . Util::backquote($this->table) . ';');
     $primary = '';
     while ($row = $this->dbi->fetchAssoc($result)) {
         // Backups the list of primary keys
         if ($row['Key_name'] == 'PRIMARY') {
             $primary .= $row['Column_name'] . ', ';
         }
     }
     // end while
     $this->dbi->freeResult($result);
     return $primary;
 }
开发者ID:Gemorroj,项目名称:phpmyadmin,代码行数:20,代码来源:TableStructureController.php

示例12: _getAllowedTabs

 /**
  * Returns a list of allowed tabs for the current user for the given level
  *
  * @param string $level 'server', 'db' or 'table' level
  *
  * @return array list of allowed tabs
  */
 private function _getAllowedTabs($level)
 {
     $cache_key = 'menu-levels-' . $level;
     if (Util::cacheExists($cache_key)) {
         return Util::cacheGet($cache_key);
     }
     $allowedTabs = Util::getMenuTabList($level);
     $cfgRelation = PMA_getRelationsParam();
     if ($cfgRelation['menuswork']) {
         $groupTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['usergroups']);
         $userTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['users']);
         $sql_query = "SELECT `tab` FROM " . $groupTable . " WHERE `allowed` = 'N'" . " AND `tab` LIKE '" . $level . "%'" . " AND `usergroup` = (SELECT usergroup FROM " . $userTable . " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "')";
         $result = PMA_queryAsControlUser($sql_query, false);
         if ($result) {
             while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
                 $tabName = mb_substr($row['tab'], mb_strpos($row['tab'], '_') + 1);
                 unset($allowedTabs[$tabName]);
             }
         }
     }
     Util::cacheSet($cache_key, $allowedTabs);
     return $allowedTabs;
 }
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:30,代码来源:Menu.php

示例13: _modifySqlQuery

 /**
  * Returns sql for fetching raw data
  *
  * @param string  $sql_query The SQL to modify.
  * @param integer $rows      Number of rows.
  * @param integer $pos       Start position.
  *
  * @return string the modified sql query.
  */
 private function _modifySqlQuery($sql_query, $rows, $pos)
 {
     $modified_query = 'SELECT ';
     // If label column is chosen add it to the query
     if (!empty($this->_userSpecifiedSettings['labelColumn'])) {
         $modified_query .= Util::backquote($this->_userSpecifiedSettings['labelColumn']) . ', ';
     }
     // Wrap the spatial column with 'ASTEXT()' function and add it
     $modified_query .= 'ASTEXT(' . Util::backquote($this->_userSpecifiedSettings['spatialColumn']) . ') AS ' . Util::backquote($this->_userSpecifiedSettings['spatialColumn']) . ', ';
     // Get the SRID
     $modified_query .= 'SRID(' . Util::backquote($this->_userSpecifiedSettings['spatialColumn']) . ') AS ' . Util::backquote('srid') . ' ';
     // Append the original query as the inner query
     $modified_query .= 'FROM (' . $sql_query . ') AS ' . Util::backquote('temp_gis');
     // LIMIT clause
     if (is_numeric($rows) && $rows > 0) {
         $modified_query .= ' LIMIT ';
         if (is_numeric($pos) && $pos >= 0) {
             $modified_query .= $pos . ', ' . $rows;
         } else {
             $modified_query .= $rows;
         }
     }
     return $modified_query;
 }
开发者ID:rugbyprof,项目名称:phpmyadmin,代码行数:33,代码来源:GISVisualization.php

示例14: PMA_findDistinctValuesCount

/**
 * function to get distinct values count of all the column in the array $columns
 *
 * @param array  $columns array of backquoted columns whose distinct values
 * need to be counted.
 * @param string $table   table to which these columns belong
 *
 * @return array associative array containing the count
 */
function PMA_findDistinctValuesCount($columns, $table)
{
    $result = array();
    $query = 'SELECT ';
    foreach ($columns as $column) {
        if ($column) {
            //each column is already backquoted
            $query .= 'COUNT(DISTINCT ' . $column . ') as \'' . $column . '_cnt\', ';
        }
    }
    $query = trim($query, ', ');
    $query .= ' FROM (SELECT * FROM ' . Util::backquote($table) . ' LIMIT 500) as dt' . ';';
    $res = $GLOBALS['dbi']->fetchResult($query, null, null, $GLOBALS['userlink']);
    foreach ($columns as $column) {
        if ($column) {
            $result[$column] = $res[0][$column . '_cnt'];
        }
    }
    return $result;
}
开发者ID:flash1452,项目名称:phpmyadmin,代码行数:29,代码来源:normalization.lib.php

示例15: loadPrimaryKey

 /**
  * Loads the PRIMARY key.
  *
  * @return void
  */
 protected function loadPrimaryKey()
 {
     $result = $GLOBALS['dbi']->query('SHOW INDEX FROM ' . PMA\libraries\Util::backquote($this->tableName) . ';', null, PMA\libraries\DatabaseInterface::QUERY_STORE);
     if ($GLOBALS['dbi']->numRows($result) > 0) {
         while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
             if ($row['Key_name'] == 'PRIMARY') {
                 $this->primary[] = $row['Column_name'];
             }
         }
     }
 }
开发者ID:netroby,项目名称:phpmyadmin,代码行数:16,代码来源:TableStats.php


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