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


PHP Context::MODE方法代码示例

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


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

示例1: 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   $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
  * @param bool   $update_indexes_increments whether we need to update
  *                                          two global variables
  * @param array  $aliases                   Aliases of db/table/columns
  *
  * @return string resulting schema
  */
 public function getTableDef($db, $table, $crlf, $error_url, $show_dates = false, $add_semicolon = true, $view = false, $update_indexes_increments = true, $aliases = array())
 {
     global $sql_drop_table, $sql_backquotes, $sql_constraints, $sql_constraints_query, $sql_indexes, $sql_indexes_query, $sql_auto_increments, $sql_drop_foreign_keys;
     $db_alias = $db;
     $table_alias = $table;
     $this->initAlias($aliases, $db_alias, $table_alias);
     $schema_create = '';
     $auto_increment = '';
     $new_crlf = $crlf;
     if (isset($GLOBALS['sql_compatibility'])) {
         $compat = $GLOBALS['sql_compatibility'];
     } else {
         $compat = 'NONE';
     }
     // need to use PMA\libraries\DatabaseInterface::QUERY_STORE
     // with $GLOBALS['dbi']->numRows() in mysqli
     $result = $GLOBALS['dbi']->query('SHOW TABLE STATUS FROM ' . Util::backquote($db) . ' WHERE Name = \'' . Util::sqlAddSlashes($table) . '\'', null, DatabaseInterface::QUERY_STORE);
     if ($result != false) {
         if ($GLOBALS['dbi']->numRows($result) > 0) {
             $tmpres = $GLOBALS['dbi']->fetchAssoc($result);
             // Here we optionally add the AUTO_INCREMENT next value,
             // but starting with MySQL 5.0.24, the clause is already included
             // in SHOW CREATE TABLE so we'll remove it below
             if (isset($GLOBALS['sql_auto_increment']) && !empty($tmpres['Auto_increment'])) {
                 $auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' ';
             }
             if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) {
                 $schema_create .= $this->_exportComment(__('Creation:') . ' ' . Util::localisedDate(strtotime($tmpres['Create_time'])));
                 $new_crlf = $this->_exportComment() . $crlf;
             }
             if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) {
                 $schema_create .= $this->_exportComment(__('Last update:') . ' ' . Util::localisedDate(strtotime($tmpres['Update_time'])));
                 $new_crlf = $this->_exportComment() . $crlf;
             }
             if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) {
                 $schema_create .= $this->_exportComment(__('Last check:') . ' ' . Util::localisedDate(strtotime($tmpres['Check_time'])));
                 $new_crlf = $this->_exportComment() . $crlf;
             }
         }
         $GLOBALS['dbi']->freeResult($result);
     }
     $schema_create .= $new_crlf;
     // no need to generate a DROP VIEW here, it was done earlier
     if (!empty($sql_drop_table) && !$GLOBALS['dbi']->getTable($db, $table)->isView()) {
         $schema_create .= 'DROP TABLE IF EXISTS ' . Util::backquote($table_alias, $sql_backquotes) . ';' . $crlf;
     }
     // Complete table dump,
     // Whether to quote table and column names or not
     if ($sql_backquotes) {
         $GLOBALS['dbi']->query('SET SQL_QUOTE_SHOW_CREATE = 1');
     } else {
         $GLOBALS['dbi']->query('SET SQL_QUOTE_SHOW_CREATE = 0');
     }
     // I don't see the reason why this unbuffered query could cause problems,
     // because SHOW CREATE TABLE returns only one row, and we free the
     // results below. Nonetheless, we got 2 user reports about this
     // (see bug 1562533) so I removed the unbuffered mode.
     // $result = $GLOBALS['dbi']->query('SHOW CREATE TABLE ' . backquote($db)
     // . '.' . backquote($table), null, DatabaseInterface::QUERY_UNBUFFERED);
     //
     // Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not
     // produce a displayable result for the default value of a BIT
     // column, nor does the mysqldump command. See MySQL bug 35796
     $result = $GLOBALS['dbi']->tryQuery('SHOW CREATE TABLE ' . Util::backquote($db) . '.' . Util::backquote($table));
     // an error can happen, for example the table is crashed
     $tmp_error = $GLOBALS['dbi']->getError();
     if ($tmp_error) {
         return $this->_exportComment(__('in use') . '(' . $tmp_error . ')');
     }
     // Old mode is stored so it can be restored once exporting is done.
     $old_mode = Context::$MODE;
     $warning = '';
     if ($result != false && ($row = $GLOBALS['dbi']->fetchRow($result))) {
         $create_query = $row[1];
         unset($row);
         // Convert end of line chars to one that we want (note that MySQL
         // doesn't return query it will accept in all cases)
         if (mb_strpos($create_query, "(\r\n ")) {
             $create_query = str_replace("\r\n", $crlf, $create_query);
         } elseif (mb_strpos($create_query, "(\n ")) {
             $create_query = str_replace("\n", $crlf, $create_query);
//.........这里部分代码省略.........
开发者ID:ryanfmurphy,项目名称:phpmyadmin,代码行数:101,代码来源:ExportSql.php


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