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


PHP PMA_DBI_get_procedures_or_functions函数代码示例

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


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

示例1: exportRoutines

 /**
  * Exports routines (procedures and functions)
  *
  * @param string $db Database
  *
  * @return bool Whether it succeeded
  */
 public function exportRoutines($db)
 {
     global $crlf;
     $text = '';
     $delimiter = '$$';
     $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
     $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
     if ($procedure_names || $function_names) {
         $text .= $crlf . 'DELIMITER ' . $delimiter . $crlf;
     }
     if ($procedure_names) {
         $text .= $this->_exportComment() . $this->_exportComment(__('Procedures')) . $this->_exportComment();
         foreach ($procedure_names as $procedure_name) {
             if (!empty($GLOBALS['sql_drop_table'])) {
                 $text .= 'DROP PROCEDURE IF EXISTS ' . PMA_Util::backquote($procedure_name) . $delimiter . $crlf;
             }
             $text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
         }
     }
     if ($function_names) {
         $text .= $this->_exportComment() . $this->_exportComment(__('Functions')) . $this->_exportComment();
         foreach ($function_names as $function_name) {
             if (!empty($GLOBALS['sql_drop_table'])) {
                 $text .= 'DROP FUNCTION IF EXISTS ' . PMA_Util::backquote($function_name) . $delimiter . $crlf;
             }
             $text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf;
         }
     }
     if ($procedure_names || $function_names) {
         $text .= 'DELIMITER ;' . $crlf;
     }
     if (!empty($text)) {
         return PMA_exportOutputHandler($text);
     } else {
         return false;
     }
 }
开发者ID:fanscky,项目名称:HTPMS,代码行数:44,代码来源:ExportSql.class.php

示例2: PMA_DBI_get_procedures_or_functions

     // language; I have to send each statement one by one
     // to avoid selecting alternatively the current and new db
     // we would need to modify the CREATE definitions to qualify
     // the db name
     $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
     if ($procedure_names) {
         foreach ($procedure_names as $procedure_name) {
             PMA_DBI_select_db($db);
             $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
             // collect for later display
             $GLOBALS['sql_query'] .= "\n" . $tmp_query;
             PMA_DBI_select_db($newname);
             PMA_DBI_query($tmp_query);
         }
     }
     $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
     if ($function_names) {
         foreach ($function_names as $function_name) {
             PMA_DBI_select_db($db);
             $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
             // collect for later display
             $GLOBALS['sql_query'] .= "\n" . $tmp_query;
             PMA_DBI_select_db($newname);
             PMA_DBI_query($tmp_query);
         }
     }
 }
 // go back to current db, just in case
 PMA_DBI_select_db($db);
 // Duplicate the bookmarks for this db (done once for each db)
 if (!$_error && $db != $newname) {
开发者ID:lavsurgut,项目名称:autoauc2,代码行数:31,代码来源:db_operations.php

示例3: exportHeader

 /**
  * Outputs export header. It is the first method to be called, so all
  * the required variables are initialized here.
  *
  * @return bool Whether it succeeded
  */
 public function exportHeader()
 {
     $this->initSpecificVariables();
     global $crlf, $cfg, $db;
     $table = $this->_getTable();
     $tables = $this->_getTables();
     $export_struct = isset($GLOBALS['xml_export_functions']) || isset($GLOBALS['xml_export_procedures']) || isset($GLOBALS['xml_export_tables']) || isset($GLOBALS['xml_export_triggers']) || isset($GLOBALS['xml_export_views']);
     $export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
     if ($GLOBALS['output_charset_conversion']) {
         $charset = $GLOBALS['charset_of_file'];
     } else {
         $charset = 'utf-8';
     }
     $head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf . '<!--' . $crlf . '- phpMyAdmin XML Dump' . $crlf . '- version ' . PMA_VERSION . $crlf . '- http://www.phpmyadmin.net' . $crlf . '-' . $crlf . '- ' . __('Host') . ': ' . $cfg['Server']['host'];
     if (!empty($cfg['Server']['port'])) {
         $head .= ':' . $cfg['Server']['port'];
     }
     $head .= $crlf . '- ' . __('Generation Time') . ': ' . PMA_Util::localisedDate() . $crlf . '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf . '- ' . __('PHP Version') . ': ' . phpversion() . $crlf . '-->' . $crlf . $crlf;
     $head .= '<pma_xml_export version="1.0"' . ($export_struct ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
     if ($export_struct) {
         if (PMA_DRIZZLE) {
             $result = PMA_DBI_fetch_result("SELECT\n                        'utf8' AS DEFAULT_CHARACTER_SET_NAME,\n                        DEFAULT_COLLATION_NAME\n                    FROM data_dictionary.SCHEMAS\n                    WHERE SCHEMA_NAME = '" . PMA_Util::sqlAddSlashes($db) . "'");
         } else {
             $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`' . ' FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`' . ' = \'' . PMA_Util::sqlAddSlashes($db) . '\' LIMIT 1');
         }
         $db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
         $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
         $head .= '    <!--' . $crlf;
         $head .= '    - Structure schemas' . $crlf;
         $head .= '    -->' . $crlf;
         $head .= '    <pma:structure_schemas>' . $crlf;
         $head .= '        <pma:database name="' . htmlspecialchars($db) . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
         if (count($tables) == 0) {
             $tables[] = $table;
         }
         foreach ($tables as $table) {
             // Export tables and views
             $result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table), 0);
             $tbl = $result[$table][1];
             $is_view = PMA_Table::isView($db, $table);
             if ($is_view) {
                 $type = 'view';
             } else {
                 $type = 'table';
             }
             if ($is_view && !isset($GLOBALS['xml_export_views'])) {
                 continue;
             }
             if (!$is_view && !isset($GLOBALS['xml_export_tables'])) {
                 continue;
             }
             $head .= '            <pma:' . $type . ' name="' . $table . '">' . $crlf;
             $tbl = "                " . htmlspecialchars($tbl);
             $tbl = str_replace("\n", "\n                ", $tbl);
             $head .= $tbl . ';' . $crlf;
             $head .= '            </pma:' . $type . '>' . $crlf;
             if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
                 // Export triggers
                 $triggers = PMA_DBI_get_triggers($db, $table);
                 if ($triggers) {
                     foreach ($triggers as $trigger) {
                         $code = $trigger['create'];
                         $head .= '            <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
                         // Do some formatting
                         $code = substr(rtrim($code), 0, -3);
                         $code = "                " . htmlspecialchars($code);
                         $code = str_replace("\n", "\n                ", $code);
                         $head .= $code . $crlf;
                         $head .= '            </pma:trigger>' . $crlf;
                     }
                     unset($trigger);
                     unset($triggers);
                 }
             }
         }
         if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
             // Export functions
             $functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
             if ($functions) {
                 foreach ($functions as $function) {
                     $head .= '            <pma:function name="' . $function . '">' . $crlf;
                     // Do some formatting
                     $sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
                     $sql = rtrim($sql);
                     $sql = "                " . htmlspecialchars($sql);
                     $sql = str_replace("\n", "\n                ", $sql);
                     $head .= $sql . $crlf;
                     $head .= '            </pma:function>' . $crlf;
                 }
                 unset($function);
                 unset($functions);
             }
         }
         if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
//.........这里部分代码省略.........
开发者ID:yxwzaxns,项目名称:sakura,代码行数:101,代码来源:ExportXml.class.php

示例4: PMA_exportHeader

 /**
  * Outputs export header
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportHeader()
 {
     global $crlf;
     global $cfg;
     global $what;
     global $db;
     global $table;
     global $tables;
     $export_struct = isset($GLOBALS[$what . '_export_struc']) ? true : false;
     $export_data = isset($GLOBALS[$what . '_export_contents']) ? true : false;
     if ($GLOBALS['output_charset_conversion']) {
         $charset = $GLOBALS['charset_of_file'];
     } else {
         $charset = $GLOBALS['charset'];
     }
     $head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf . '<!--' . $crlf . '- phpMyAdmin XML Dump' . $crlf . '- version ' . PMA_VERSION . $crlf . '- http://www.phpmyadmin.net' . $crlf . '-' . $crlf . '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
     if (!empty($cfg['Server']['port'])) {
         $head .= ':' . $cfg['Server']['port'];
     }
     $head .= $crlf . '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf . '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf . '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf . '-->' . $crlf . $crlf;
     $head .= '<pma_xml_export version="1.0"' . ($export_struct ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
     if ($export_struct) {
         $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \'' . $db . '\' LIMIT 1');
         $db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
         $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
         $head .= '    <!--' . $crlf;
         $head .= '    - Structure schemas' . $crlf;
         $head .= '    -->' . $crlf;
         $head .= '    <pma:structure_schemas>' . $crlf;
         $head .= '        <pma:database name="' . $db . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
         if (count($tables) == 0) {
             $tables[] = $table;
         }
         foreach ($tables as $table) {
             // Export tables and views
             $result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0);
             $tbl = $result[$table][1];
             $is_view = PMA_isView($db, $table);
             if ($is_view) {
                 $type = 'view';
             } else {
                 $type = 'table';
             }
             if ($is_view && !isset($GLOBALS[$what . '_export_views'])) {
                 continue;
             }
             if (!$is_view && !isset($GLOBALS[$what . '_export_tables'])) {
                 continue;
             }
             $head .= '            <pma:' . $type . ' name="' . $table . '">' . $crlf;
             $tbl = "                " . $tbl;
             $tbl = str_replace("\n", "\n                ", $tbl);
             $head .= $tbl . ';' . $crlf;
             $head .= '            </pma:' . $type . '>' . $crlf;
             if (isset($GLOBALS[$what . '_export_triggers']) && $GLOBALS[$what . '_export_triggers']) {
                 // Export triggers
                 $triggers = PMA_DBI_get_triggers($db, $table);
                 if ($triggers) {
                     foreach ($triggers as $trigger) {
                         $code = $trigger['create'];
                         $head .= '            <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
                         // Do some formatting
                         $code = substr(rtrim($code), 0, -3);
                         $code = "                " . $code;
                         $code = str_replace("\n", "\n                ", $code);
                         $head .= $code . $crlf;
                         $head .= '            </pma:trigger>' . $crlf;
                     }
                     unset($trigger);
                     unset($triggers);
                 }
             }
         }
         if (isset($GLOBALS[$what . '_export_functions']) && $GLOBALS[$what . '_export_functions']) {
             // Export functions
             $functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
             if ($functions) {
                 foreach ($functions as $function) {
                     $head .= '            <pma:function name="' . $function . '">' . $crlf;
                     // Do some formatting
                     $sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
                     $sql = rtrim($sql);
                     $sql = "                " . $sql;
                     $sql = str_replace("\n", "\n                ", $sql);
                     $head .= $sql . $crlf;
                     $head .= '            </pma:function>' . $crlf;
                 }
                 unset($create_func);
                 unset($function);
                 unset($functions);
             }
         }
         if (isset($GLOBALS[$what . '_export_procedures']) && $GLOBALS[$what . '_export_procedures']) {
//.........这里部分代码省略.........
开发者ID:kolbermoorer,项目名称:edugame,代码行数:101,代码来源:xml.php

示例5: PMA_exportDBFooter

 /**
  * Outputs database footer
  *
  * @param   string      Database name
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportDBFooter($db)
 {
     global $crlf;
     $result = TRUE;
     if (isset($GLOBALS['sql_constraints'])) {
         $result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
         unset($GLOBALS['sql_constraints']);
     }
     if (PMA_MYSQL_INT_VERSION >= 50000 && isset($GLOBALS['sql_structure']) && isset($GLOBALS['sql_procedure_function'])) {
         $procs_funcs = '';
         $delimiter = '$$';
         $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
         $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
         if ($procedure_names || $function_names) {
             $procs_funcs .= $crlf . 'DELIMITER ' . $delimiter . $crlf;
         }
         if ($procedure_names) {
             $procs_funcs .= PMA_exportComment() . PMA_exportComment($GLOBALS['strProcedures']) . PMA_exportComment();
             foreach ($procedure_names as $procedure_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $procs_funcs .= 'DROP PROCEDURE ' . PMA_backquote($procedure_name) . $delimiter . $crlf;
                 }
                 $procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($function_names) {
             $procs_funcs .= PMA_exportComment() . PMA_exportComment($GLOBALS['strFunctions']) . PMA_exportComment();
             foreach ($function_names as $function_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $procs_funcs .= 'DROP FUNCTION ' . PMA_backquote($function_name) . $delimiter . $crlf;
                 }
                 $procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($procedure_names || $function_names) {
             $procs_funcs .= 'DELIMITER ;' . $crlf;
         }
         if (!empty($procs_funcs)) {
             $result = PMA_exportOutputHandler($procs_funcs);
         }
     }
     return $result;
 }
开发者ID:findlakes,项目名称:XSS-Platform,代码行数:52,代码来源:sql.php

示例6: PMA_exportDBFooter

 /**
  * Outputs database footer
  *
  * @param   string      Database name
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportDBFooter($db)
 {
     global $crlf;
     $result = TRUE;
     if (isset($GLOBALS['sql_constraints'])) {
         $result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
         unset($GLOBALS['sql_constraints']);
     }
     if (isset($GLOBALS['sql_structure']) && isset($GLOBALS['sql_procedure_function'])) {
         $text = '';
         $delimiter = '$$';
         $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
         $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
         if (PMA_MYSQL_INT_VERSION > 50100) {
             $event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddslashes($db, true) . '\';');
         } else {
             $event_names = array();
         }
         if ($procedure_names || $function_names || $event_names) {
             $text .= $crlf . 'DELIMITER ' . $delimiter . $crlf;
         }
         if ($procedure_names) {
             $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strProcedures']) . PMA_exportComment();
             foreach ($procedure_names as $procedure_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $text .= 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($procedure_name) . $delimiter . $crlf;
                 }
                 $text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($function_names) {
             $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strFunctions']) . PMA_exportComment();
             foreach ($function_names as $function_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $text .= 'DROP FUNCTION IF EXISTS ' . PMA_backquote($function_name) . $delimiter . $crlf;
                 }
                 $text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($event_names) {
             $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strEvents']) . PMA_exportComment();
             foreach ($event_names as $event_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $text .= 'DROP EVENT ' . PMA_backquote($event_name) . $delimiter . $crlf;
                 }
                 $text .= PMA_DBI_get_definition($db, 'EVENT', $event_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($procedure_names || $function_names || $event_names) {
             $text .= 'DELIMITER ;' . $crlf;
         }
         if (!empty($text)) {
             $result = PMA_exportOutputHandler($text);
         }
     }
     return $result;
 }
开发者ID:huangs0928,项目名称:zzlangshi,代码行数:66,代码来源:sql.php

示例7: PMA_exportDBFooter

 /**
  * Outputs database footer
  *
  * @param   string      Database name
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportDBFooter($db)
 {
     global $crlf, $comment_marker;
     $result = TRUE;
     if (isset($GLOBALS['sql_constraints'])) {
         $result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
         unset($GLOBALS['sql_constraints']);
     }
     if (PMA_MYSQL_INT_VERSION >= 50000) {
         $procs_funcs = '';
         $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
         if ($procedure_names) {
             $delimiter = '$$';
             $procs_funcs = $crlf . $comment_marker . $crlf . $comment_marker . $GLOBALS['strProcedures'] . $crlf . $comment_marker . $crlf . $comment_marker . 'DELIMITER ' . $delimiter . $crlf . $comment_marker . $crlf;
             foreach ($procedure_names as $procedure_name) {
                 $procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
             }
             $procs_funcs .= $comment_marker . $crlf . $comment_marker . 'DELIMITER ;' . $crlf . $comment_marker . $crlf;
         }
         $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
         if ($function_names) {
             $procs_funcs .= $comment_marker . $GLOBALS['strFunctions'] . $crlf . $comment_marker . $crlf . $crlf;
             foreach ($function_names as $function_name) {
                 $procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'FUNCTION', $function_name) . $crlf . $crlf;
             }
         }
         if (!empty($procs_funcs)) {
             $result = PMA_exportOutputHandler($procs_funcs);
         }
     }
     return $result;
 }
开发者ID:BGCX261,项目名称:zhss-svn-to-git,代码行数:41,代码来源:sql.php

示例8: PMA_runProcedureAndFunctionDefinitions

/**
 * Run the Procedure definitions and function definitions
 *
 * to avoid selecting alternatively the current and new db
 * we would need to modify the CREATE definitions to qualify
 * the db name
 *
 * @param string $db database name
 *
 * @return void
 */
function PMA_runProcedureAndFunctionDefinitions($db)
{
    $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
    if ($procedure_names) {
        foreach ($procedure_names as $procedure_name) {
            PMA_DBI_select_db($db);
            $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
            // collect for later display
            $GLOBALS['sql_query'] .= "\n" . $tmp_query;
            PMA_DBI_select_db($_REQUEST['newname']);
            PMA_DBI_query($tmp_query);
        }
    }
    $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
    if ($function_names) {
        foreach ($function_names as $function_name) {
            PMA_DBI_select_db($db);
            $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
            // collect for later display
            $GLOBALS['sql_query'] .= "\n" . $tmp_query;
            PMA_DBI_select_db($_REQUEST['newname']);
            PMA_DBI_query($tmp_query);
        }
    }
}
开发者ID:fanscky,项目名称:HTPMS,代码行数:36,代码来源:operations.lib.php

示例9: PMA_exportDBCreate

 /**
  * Outputs CREATE DATABASE database
  *
  * @param   string      Database name
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportDBCreate($db)
 {
     global $crlf;
     if (isset($GLOBALS['sql_drop_database'])) {
         if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
             return FALSE;
         }
     }
     $create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db);
     $collation = PMA_getDbCollation($db);
     if (strpos($collation, '_')) {
         $create_query .= ' DEFAULT CHARACTER SET ' . substr($collation, 0, strpos($collation, '_')) . ' COLLATE ' . $collation;
     } else {
         $create_query .= ' DEFAULT CHARACTER SET ' . $collation;
     }
     $create_query .= ';' . $crlf;
     if (!PMA_exportOutputHandler($create_query)) {
         return FALSE;
     }
     if (isset($GLOBALS['sql_backquotes']) && isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'NONE') {
         $result = PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
     } else {
         $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
     }
     if ($result && isset($GLOBALS['sql_structure']) && isset($GLOBALS['sql_procedure_function'])) {
         $text = '';
         $delimiter = '$$';
         $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
         $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
         if ($procedure_names || $function_names) {
             $text .= $crlf . 'DELIMITER ' . $delimiter . $crlf;
         }
         if ($procedure_names) {
             $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strProcedures']) . PMA_exportComment();
             foreach ($procedure_names as $procedure_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $text .= 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($procedure_name) . $delimiter . $crlf;
                 }
                 $text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($function_names) {
             $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strFunctions']) . PMA_exportComment();
             foreach ($function_names as $function_name) {
                 if (!empty($GLOBALS['sql_drop_table'])) {
                     $text .= 'DROP FUNCTION IF EXISTS ' . PMA_backquote($function_name) . $delimiter . $crlf;
                 }
                 $text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf;
             }
         }
         if ($procedure_names || $function_names) {
             $text .= 'DELIMITER ;' . $crlf;
         }
         if (!empty($text)) {
             $result = PMA_exportOutputHandler($text);
         }
     }
     return $result;
 }
开发者ID:wdingsoft,项目名称:test1.jit,代码行数:68,代码来源:sql.php


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