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


PHP PMA_Util::backquoteCompat方法代码示例

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


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

示例1: exportData

 /**
  * Outputs the content of a table in SQL format
  *
  * @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 $sql_query SQL query for obtaining data
  *
  * @return bool Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $current_row, $sql_backquotes;
     if (isset($GLOBALS['sql_compatibility'])) {
         $compat = $GLOBALS['sql_compatibility'];
     } else {
         $compat = 'NONE';
     }
     $formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_Util::backquoteCompat($table, $compat) : '\'' . $table . '\'';
     // Do not export data for a VIEW
     // (For a VIEW, this is called only when exporting a single VIEW)
     if (PMA_Table::isView($db, $table)) {
         $head = $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment('VIEW ' . ' ' . $formatted_table_name) . $this->_exportComment(__('Data') . ': ' . __('None')) . $this->_exportComment() . $this->_possibleCRLF();
         if (!PMA_exportOutputHandler($head)) {
             return false;
         }
         return true;
     }
     // analyze the query to get the true column names, not the aliases
     // (this fixes an undefined index, also if Complete inserts
     //  are used, we did not get the true column name in case of aliases)
     $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query));
     $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     // a possible error: the table has crashed
     $tmp_error = PMA_DBI_getError();
     if ($tmp_error) {
         return PMA_exportOutputHandler($this->_exportComment(__('Error reading data:') . ' (' . $tmp_error . ')'));
     }
     if ($result != false) {
         $fields_cnt = PMA_DBI_num_fields($result);
         // Get field information
         $fields_meta = PMA_DBI_get_fields_meta($result);
         $field_flags = array();
         for ($j = 0; $j < $fields_cnt; $j++) {
             $field_flags[$j] = PMA_DBI_field_flags($result, $j);
         }
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
                 $field_set[$j] = PMA_Util::backquoteCompat($analyzed_sql[0]['select_expr'][$j]['column'], $compat, $sql_backquotes);
             } else {
                 $field_set[$j] = PMA_Util::backquoteCompat($fields_meta[$j]->name, $compat, $sql_backquotes);
             }
         }
         if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
             // update
             $schema_insert = 'UPDATE ';
             if (isset($GLOBALS['sql_ignore'])) {
                 $schema_insert .= 'IGNORE ';
             }
             // avoid EOL blank
             $schema_insert .= PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' SET';
         } else {
             // insert or replace
             if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'REPLACE') {
                 $sql_command = 'REPLACE';
             } else {
                 $sql_command = 'INSERT';
             }
             // delayed inserts?
             if (isset($GLOBALS['sql_delayed'])) {
                 $insert_delayed = ' DELAYED';
             } else {
                 $insert_delayed = '';
             }
             // insert ignore?
             if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'INSERT' && isset($GLOBALS['sql_ignore'])) {
                 $insert_delayed .= ' IGNORE';
             }
             //truncate table before insert
             if (isset($GLOBALS['sql_truncate']) && $GLOBALS['sql_truncate'] && $sql_command == 'INSERT') {
                 $truncate = 'TRUNCATE TABLE ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ";";
                 $truncatehead = $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('Truncate table before insert') . ' ' . $formatted_table_name) . $this->_exportComment() . $crlf;
                 PMA_exportOutputHandler($truncatehead);
                 PMA_exportOutputHandler($truncate);
             } else {
                 $truncate = '';
             }
             // scheme for inserting fields
             if ($GLOBALS['sql_insert_syntax'] == 'complete' || $GLOBALS['sql_insert_syntax'] == 'both') {
                 $fields = implode(', ', $field_set);
                 $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' (' . $fields . ') VALUES';
             } else {
                 $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' VALUES';
             }
         }
         //\x08\\x09, not required
         $search = array("", "\n", "\r", "");
         $replace = array('\\0', '\\n', '\\r', '\\Z');
         $current_row = 0;
//.........这里部分代码省略.........
开发者ID:fanscky,项目名称:HTPMS,代码行数:101,代码来源:ExportSql.class.php

示例2: testbackquoteCompat

 /**
  * backquoteCompat test with different param $compatibility (NONE, MSSQL)
  *
  * @param string $a String
  * @param string $b Expected output
  *
  * @return void
  *
  * @dataProvider backquoteCompatDataProvider
  */
 public function testbackquoteCompat($a, $b)
 {
     // Test bypass quoting (used by dump functions)
     $this->assertEquals($a, PMA_Util::backquoteCompat($a, 'NONE', false));
     // Run tests in MSSQL compatibility mode
     // Test bypass quoting (used by dump functions)
     $this->assertEquals($a, PMA_Util::backquoteCompat($a, 'MSSQL', false));
     // Test backquote
     $this->assertEquals($b, PMA_Util::backquoteCompat($a, 'MSSQL'));
 }
开发者ID:xtreme-jamil-shamy,项目名称:phpmyadmin-cf,代码行数:20,代码来源:PMA_quoting_slashing_test.php

示例3: generateComment

 /**
  * Generate comment
  *
  * @param string $crlf          Carriage return character
  * @param string $sql_statement SQL statement
  * @param string $comment1      Comment for dumped table
  * @param string $comment2      Comment for current table
  * @param string $table_alias   Table alias
  * @param string $compat        Compatibility mode
  *
  * @return string
  */
 protected function generateComment($crlf, $sql_statement, $comment1, $comment2, $table_alias, $compat)
 {
     if (!isset($sql_statement)) {
         if (isset($GLOBALS['no_constraints_comments'])) {
             $sql_statement = '';
         } else {
             $sql_statement = $crlf . $this->_exportComment() . $this->_exportComment($comment1) . $this->_exportComment();
         }
     }
     // comments for current table
     if (!isset($GLOBALS['no_constraints_comments'])) {
         $sql_statement .= $crlf . $this->_exportComment() . $this->_exportComment($comment2 . ' ' . PMA_Util::backquoteCompat($table_alias, $compat, isset($GLOBALS['sql_backquotes']))) . $this->_exportComment();
     }
     return $sql_statement;
 }
开发者ID:joshuawatson,项目名称:phpmyadmin,代码行数:27,代码来源:ExportSql.class.php

示例4: testbackquoteCompat

    /**
     * backquoteCompat test with different param $compatibility (NONE, MSSQL)
     * @dataProvider backquoteCompatDataProvider
     */
    public function testbackquoteCompat($a, $b)
    {
        // Test bypass quoting (used by dump functions)
        $this->assertEquals($a, PMA_Util::backquoteCompat($a, 'NONE', false));

        // Test backquote (backquoting will be enabled only if isset $GLOBALS['sql_backquotes']
        $this->assertEquals($a, PMA_Util::backquoteCompat($a, 'NONE'));

        // Run tests in MSSQL compatibility mode
        // Test bypass quoting (used by dump functions)
        $this->assertEquals($a, PMA_Util::backquoteCompat($a, 'MSSQL', false));

        // Test backquote
        $this->assertEquals($b, PMA_Util::backquoteCompat($a, 'MSSQL'));
    }
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:19,代码来源:PMA_quoting_slashing_test.php


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