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


PHP PMA_analyzeTable函数代码示例

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


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

示例1: array

        }
        $tables[] = array($sheet_names[$s], $col_names, $rows);
        $col_names = array();
        $rows = array();
    }
}
unset($objPHPExcel);
unset($objReader);
unset($rows);
unset($tempRow);
unset($col_names);
/* Obtain the best-fit MySQL types for each column */
$analyses = array();
$len = count($tables);
for ($i = 0; $i < $len; ++$i) {
    $analyses[] = PMA_analyzeTable($tables[$i]);
}
/**
 * string $db_name (no backquotes)
 *
 * array $table = array(table_name, array() column_names, array()() rows)
 * array $tables = array of "$table"s
 *
 * array $analysis = array(array() column_types, array() column_sizes)
 * array $analyses = array of "$analysis"s
 *
 * array $create = array of SQL strings
 *
 * array $options = an associative array of options
 */
/* Set database name to the currently selected one, if applicable */
开发者ID:kolbermoorer,项目名称:edugame,代码行数:31,代码来源:xls.php

示例2: _importDataOneTable

 /**
  * Imports data from a single table
  *
  * @param array $table containing all table info:
  *                     <code>
  *                     $table[0] - string containing table name
  *                     $table[1] - array[]   of table headers
  *                     $table[2] - array[][] of table content rows
  *                     </code>
  *
  * @global bool $analyze whether to scan for column types
  *
  * @return void
  */
 private function _importDataOneTable($table)
 {
     $analyze = $this->_getAnalyze();
     if ($analyze) {
         // Set the table name
         $this->_setTableName($table[0]);
         // Set generic names for table headers if they don't exist
         $this->_setTableHeaders($table[1], $table[2][0]);
         // Create the tables array to be used in PMA_buildSQL()
         $tables = array();
         $tables[] = array($table[0], $table[1], $table[2]);
         // Obtain the best-fit MySQL types for each column
         $analyses = array();
         $analyses[] = PMA_analyzeTable($tables[0]);
         $this->_executeImportTables($tables, $analyses);
     }
     // Commit any possible data in buffers
     PMA_importRunQuery();
 }
开发者ID:pjiahao,项目名称:phpmyadmin,代码行数:33,代码来源:ImportMediawiki.php

示例3: doImport


//.........这里部分代码省略.........
             // ESRI PolyLine
         // ESRI PolyLine
         case 3:
             $gis_type = 'multilinestring';
             break;
             // ESRI Polygon
         // ESRI Polygon
         case 5:
             $gis_type = 'multipolygon';
             break;
             // ESRI MultiPoint
         // ESRI MultiPoint
         case 8:
             $gis_type = 'multipoint';
             break;
         default:
             $error = true;
             if (!isset($esri_types[$shp->shapeType])) {
                 $message = PMA\libraries\Message::error(__('You tried to import an invalid file or the imported file' . ' contains invalid data!'));
             } else {
                 $message = PMA\libraries\Message::error(__('MySQL Spatial Extension does not support ESRI type "%s".'));
                 $message->addParam($esri_types[$shp->shapeType]);
             }
             return;
     }
     if (isset($gis_type)) {
         /** @var GISMultilinestring|\PMA\libraries\gis\GISMultipoint|\PMA\libraries\gis\GISPoint|GISPolygon $gis_obj */
         $gis_obj = GISFactory::factory($gis_type);
     } else {
         $gis_obj = null;
     }
     $num_rows = count($shp->records);
     // If .dbf file is loaded, the number of extra data columns
     $num_data_cols = isset($shp->DBFHeader) ? count($shp->DBFHeader) : 0;
     $rows = array();
     $col_names = array();
     if ($num_rows != 0) {
         foreach ($shp->records as $record) {
             $tempRow = array();
             if ($gis_obj == null) {
                 $tempRow[] = null;
             } else {
                 $tempRow[] = "GeomFromText('" . $gis_obj->getShape($record->SHPData) . "')";
             }
             if (isset($shp->DBFHeader)) {
                 foreach ($shp->DBFHeader as $c) {
                     $cell = trim($record->DBFData[$c[0]]);
                     if (!strcmp($cell, '')) {
                         $cell = 'NULL';
                     }
                     $tempRow[] = $cell;
                 }
             }
             $rows[] = $tempRow;
         }
     }
     if (count($rows) == 0) {
         $error = true;
         $message = PMA\libraries\Message::error(__('The imported file does not contain any data!'));
         return;
     }
     // Column names for spatial column and the rest of the columns,
     // if they are available
     $col_names[] = 'SPATIAL';
     for ($n = 0; $n < $num_data_cols; $n++) {
         $col_names[] = $shp->DBFHeader[$n][0];
     }
     // Set table name based on the number of tables
     if (mb_strlen($db)) {
         $result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
         $table_name = 'TABLE ' . (count($result) + 1);
     } else {
         $table_name = 'TBL_NAME';
     }
     $tables = array(array($table_name, $col_names, $rows));
     // Use data from shape file to chose best-fit MySQL types for each column
     $analyses = array();
     $analyses[] = PMA_analyzeTable($tables[0]);
     $table_no = 0;
     $spatial_col = 0;
     $analyses[$table_no][TYPES][$spatial_col] = GEOMETRY;
     $analyses[$table_no][FORMATTEDSQL][$spatial_col] = true;
     // Set database name to the currently selected one, if applicable
     if (mb_strlen($db)) {
         $db_name = $db;
         $options = array('create_db' => false);
     } else {
         $db_name = 'SHP_DB';
         $options = null;
     }
     // Created and execute necessary SQL statements from data
     $null_param = null;
     PMA_buildSQL($db_name, $tables, $analyses, $null_param, $options);
     unset($tables);
     unset($analyses);
     $finished = true;
     $error = false;
     // Commit any possible data in buffers
     PMA_importRunQuery();
 }
开发者ID:iShareLife,项目名称:phpmyadmin,代码行数:101,代码来源:ImportShp.php

示例4: doImport


//.........这里部分代码省略.........
                         if (!$first) {
                             $sql .= ', ';
                         }
                         if ($val === null) {
                             $sql .= 'NULL';
                         } else {
                             $sql .= '\'' . PMA\libraries\Util::sqlAddSlashes($val) . '\'';
                         }
                         $first = false;
                     }
                     $sql .= ')';
                     if (isset($_POST['csv_replace'])) {
                         $sql .= " ON DUPLICATE KEY UPDATE ";
                         foreach ($fields as $field) {
                             $fieldName = PMA\libraries\Util::backquote($field['Field']);
                             $sql .= $fieldName . " = VALUES(" . $fieldName . "), ";
                         }
                         $sql = rtrim($sql, ', ');
                     }
                     /**
                      * @todo maybe we could add original line to verbose
                      * SQL in comment
                      */
                     PMA_importRunQuery($sql, $sql, $sql_data);
                 }
                 $line++;
                 $csv_finish = false;
                 $values = array();
                 $buffer = mb_substr($buffer, $i + 1);
                 $len = mb_strlen($buffer);
                 $i = 0;
                 $lasti = -1;
                 $ch = mb_substr($buffer, 0, 1);
             }
         }
         // End of parser loop
     }
     // End of import loop
     if ($this->_getAnalyze()) {
         /* Fill out all rows */
         $num_rows = count($rows);
         for ($i = 0; $i < $num_rows; ++$i) {
             for ($j = count($rows[$i]); $j < $max_cols; ++$j) {
                 $rows[$i][] = 'NULL';
             }
         }
         if (isset($_REQUEST['csv_col_names'])) {
             $col_names = array_splice($rows, 0, 1);
             $col_names = $col_names[0];
             // MySQL column names can't end with a space character.
             foreach ($col_names as $key => $col_name) {
                 $col_names[$key] = rtrim($col_name);
             }
         }
         if (isset($col_names) && count($col_names) != $max_cols || !isset($col_names)) {
             // Fill out column names
             for ($i = 0; $i < $max_cols; ++$i) {
                 $col_names[] = 'COL ' . ($i + 1);
             }
         }
         if (mb_strlen($db)) {
             $result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
             $tbl_name = 'TABLE ' . (count($result) + 1);
         } else {
             $tbl_name = 'TBL_NAME';
         }
         $tables[] = array($tbl_name, $col_names, $rows);
         /* Obtain the best-fit MySQL types for each column */
         $analyses = array();
         $analyses[] = PMA_analyzeTable($tables[0]);
         /**
          * string $db_name (no backquotes)
          *
          * array $table = array(table_name, array() column_names, array()() rows)
          * array $tables = array of "$table"s
          *
          * array $analysis = array(array() column_types, array() column_sizes)
          * array $analyses = array of "$analysis"s
          *
          * array $create = array of SQL strings
          *
          * array $options = an associative array of options
          */
         /* Set database name to the currently selected one, if applicable */
         list($db_name, $options) = $this->getDbnameAndOptions($db, 'CSV_DB');
         /* Non-applicable parameters */
         $create = null;
         /* Created and execute necessary SQL statements from data */
         PMA_buildSQL($db_name, $tables, $analyses, $create, $options, $sql_data);
         unset($tables);
         unset($analyses);
     }
     // Commit any possible data in buffers
     PMA_importRunQuery('', '', $sql_data);
     if (count($values) != 0 && !$error) {
         $message = PMA\libraries\Message::error(__('Invalid format of CSV input on line %d.'));
         $message->addParam($line);
         $error = true;
     }
 }
开发者ID:pboutin44,项目名称:maintest,代码行数:101,代码来源:ImportCsv.php

示例5: doImport


//.........这里部分代码省略.........
             if (!$col_names_in_first_row) {
                 if ($_REQUEST['ods_empty_rows']) {
                     foreach ($tempRow as $cell) {
                         if (strcmp('NULL', $cell)) {
                             $tempRows[] = $tempRow;
                             break;
                         }
                     }
                 } else {
                     $tempRows[] = $tempRow;
                 }
             }
             $col_count = 0;
             $col_names_in_first_row = false;
             $tempRow = array();
         }
         /* Skip over empty sheets */
         if (count($tempRows) == 0 || count($tempRows[0]) == 0) {
             $col_names = array();
             $tempRow = array();
             $tempRows = array();
             continue;
         }
         /**
          * Fill out each row as necessary to make
          * every one exactly as wide as the widest
          * row. This included column names.
          */
         /* Fill out column names */
         for ($i = count($col_names); $i < $max_cols; ++$i) {
             $col_names[] = PMA_getColumnAlphaName($i + 1);
         }
         /* Fill out all rows */
         $num_rows = count($tempRows);
         for ($i = 0; $i < $num_rows; ++$i) {
             for ($j = count($tempRows[$i]); $j < $max_cols; ++$j) {
                 $tempRows[$i][] = 'NULL';
             }
         }
         /* Store the table name so we know where to place the row set */
         $tbl_attr = $sheet->attributes('table', true);
         $tables[] = array((string) $tbl_attr['name']);
         /* Store the current sheet in the accumulator */
         $rows[] = array((string) $tbl_attr['name'], $col_names, $tempRows);
         $tempRows = array();
         $col_names = array();
         $max_cols = 0;
     }
     unset($tempRow);
     unset($tempRows);
     unset($col_names);
     unset($sheets);
     unset($xml);
     /**
      * Bring accumulated rows into the corresponding table
      */
     $num_tbls = count($tables);
     for ($i = 0; $i < $num_tbls; ++$i) {
         for ($j = 0; $j < count($rows); ++$j) {
             if (strcmp($tables[$i][TBL_NAME], $rows[$j][TBL_NAME])) {
                 continue;
             }
             if (!isset($tables[$i][COL_NAMES])) {
                 $tables[$i][] = $rows[$j][COL_NAMES];
             }
             $tables[$i][ROWS] = $rows[$j][ROWS];
         }
     }
     /* No longer needed */
     unset($rows);
     /* Obtain the best-fit MySQL types for each column */
     $analyses = array();
     $len = count($tables);
     for ($i = 0; $i < $len; ++$i) {
         $analyses[] = PMA_analyzeTable($tables[$i]);
     }
     /**
      * string $db_name (no backquotes)
      *
      * array $table = array(table_name, array() column_names, array()() rows)
      * array $tables = array of "$table"s
      *
      * array $analysis = array(array() column_types, array() column_sizes)
      * array $analyses = array of "$analysis"s
      *
      * array $create = array of SQL strings
      *
      * array $options = an associative array of options
      */
     /* Set database name to the currently selected one, if applicable */
     list($db_name, $options) = $this->getDbnameAndOptions($db, 'ODS_DB');
     /* Non-applicable parameters */
     $create = null;
     /* Created and execute necessary SQL statements from data */
     PMA_buildSQL($db_name, $tables, $analyses, $create, $options);
     unset($tables);
     unset($analyses);
     /* Commit any possible data in buffers */
     PMA_importRunQuery();
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:ImportOds.class.php

示例6: doImport


//.........这里部分代码省略.........
             $isInTables = false;
             $num_tables = count($tables);
             for ($i = 0; $i < $num_tables; ++$i) {
                 if (!strcmp($tables[$i][TBL_NAME], (string) $tbl_attr['name'])) {
                     $isInTables = true;
                     break;
                 }
             }
             if (!$isInTables) {
                 $tables[] = array((string) $tbl_attr['name']);
             }
             foreach ($v1 as $v2) {
                 $row_attr = $v2->attributes();
                 if (!array_search((string) $row_attr['name'], $tempRow)) {
                     $tempRow[] = (string) $row_attr['name'];
                 }
                 $tempCells[] = (string) $v2;
             }
             $rows[] = array((string) $tbl_attr['name'], $tempRow, $tempCells);
             $tempRow = array();
             $tempCells = array();
         }
         unset($tempRow);
         unset($tempCells);
         unset($xml);
         /**
          * Bring accumulated rows into the corresponding table
          */
         $num_tables = count($tables);
         for ($i = 0; $i < $num_tables; ++$i) {
             $num_rows = count($rows);
             for ($j = 0; $j < $num_rows; ++$j) {
                 if (!strcmp($tables[$i][TBL_NAME], $rows[$j][TBL_NAME])) {
                     if (!isset($tables[$i][COL_NAMES])) {
                         $tables[$i][] = $rows[$j][COL_NAMES];
                     }
                     $tables[$i][ROWS][] = $rows[$j][ROWS];
                 }
             }
         }
         unset($rows);
         if (!$struct_present) {
             $analyses = array();
             $len = count($tables);
             for ($i = 0; $i < $len; ++$i) {
                 $analyses[] = PMA_analyzeTable($tables[$i]);
             }
         }
     }
     unset($xml);
     unset($tempCells);
     unset($rows);
     /**
      * Only build SQL from data if there is data present
      */
     if ($data_present) {
         /**
          * Set values to NULL if they were not present
          * to maintain PMA_buildSQL() call integrity
          */
         if (!isset($analyses)) {
             $analyses = null;
             if (!$struct_present) {
                 $create = null;
             }
         }
     }
     /**
      * string $db_name (no backquotes)
      *
      * array $table = array(table_name, array() column_names, array()() rows)
      * array $tables = array of "$table"s
      *
      * array $analysis = array(array() column_types, array() column_sizes)
      * array $analyses = array of "$analysis"s
      *
      * array $create = array of SQL strings
      *
      * array $options = an associative array of options
      */
     /* Set database name to the currently selected one, if applicable */
     if (strlen($db)) {
         /* Override the database name in the XML file, if one is selected */
         $db_name = $db;
         $options = array('create_db' => false);
     } else {
         if ($db_name === null) {
             $db_name = 'XML_DB';
         }
         /* Set database collation/charset */
         $options = array('db_collation' => $collation, 'db_charset' => $charset);
     }
     /* Created and execute necessary SQL statements from data */
     PMA_buildSQL($db_name, $tables, $analyses, $create, $options);
     unset($analyses);
     unset($tables);
     unset($create);
     /* Commit any possible data in buffers */
     PMA_importRunQuery();
 }
开发者ID:kbigbus,项目名称:phpmyadmin,代码行数:101,代码来源:ImportXml.php


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