Documentation TYPO3 par Ameos

tbl_properties_export.php

00001 <?php
00002 /* $Id: tbl_properties_export.php,v 2.11 2005/06/11 09:22:20 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 
00009 require('./tbl_properties_common.php');
00010 $url_query .= '&amp;goto=tbl_properties_export.php&amp;back=tbl_properties_export.php';
00011 require('./tbl_properties_table_info.php');
00012 ?>
00013 
00014 <!-- Dump of a table -->
00015 <?php
00016 $export_page_title = $strViewDump;
00017 
00018 // When we have some query, we need to remove LIMIT from that and possibly
00019 // generate WHERE clause (if we are asked to export specific rows)
00020 
00021 if (isset($sql_query)) {
00022     // Parse query so we can work with tokens
00023     $parsed_sql = PMA_SQP_parse($sql_query);
00024 
00025     // Need to generate WHERE clause?
00026     if (isset($primary_key)) {
00027         // Yes => rebuild query from scracts, this doesn't work with nested
00028         // selects :-(
00029         $analyzed_sql = PMA_SQP_analyze($parsed_sql);
00030         $sql_query = 'SELECT ';
00031 
00032         if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
00033             $sql_query .= ' DISTINCT ';
00034         }
00035 
00036         $sql_query .= $analyzed_sql[0]['select_expr_clause'];
00037 
00038         if (!empty($analyzed_sql[0]['from_clause'])) {
00039             $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
00040         }
00041 
00042         if (isset($primary_key) && is_array($primary_key)) {
00043             $sql_query .= ' WHERE ';
00044             $conj = '';
00045             foreach ($primary_key AS $i => $key) {
00046                 $sql_query .= $conj . '( ' . $key . ' ) ';
00047                 $conj = 'OR ';
00048             }
00049         } elseif (!empty($analyzed_sql[0]['where_clause']))  {
00050             $sql_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
00051         }
00052         if (!empty($analyzed_sql[0]['group_by_clause'])) {
00053             $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
00054         }
00055         if (!empty($analyzed_sql[0]['having_clause'])) {
00056             $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
00057         }
00058         if (!empty($analyzed_sql[0]['order_by_clause'])) {
00059             $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
00060         }
00061     } else {
00062         // Just crop LIMIT clause
00063         $inside_bracket = FALSE;
00064         for ($i = $parsed_sql['len'] - 1; $i >= 0; $i--) {
00065             if ($parsed_sql[$i]['type'] == 'punct_bracket_close_round') {
00066                 $inside_bracket = TRUE;
00067                 continue;
00068             }
00069             if ($parsed_sql[$i]['type'] == 'punct_bracket_open_round') {
00070                 $inside_bracket = FALSE;
00071                 continue;
00072             }
00073             if (!$inside_bracket && $parsed_sql[$i]['type'] == 'alpha_reservedWord' && strtoupper($parsed_sql[$i]['data']) == 'LIMIT') {
00074                 // We found LIMIT to remove
00075                 
00076                 $sql_query = '';
00077                 
00078                 // Concatenate parts before
00079                 for ($j = 0; $j < $i; $j++) {
00080                     $sql_query .= $parsed_sql[$j]['data'] . ' ';
00081                 }
00082                 
00083                 // Skip LIMIT
00084                 $i++;
00085                 while ($i < $parsed_sql['len'] &&
00086                     ($parsed_sql[$i]['type'] != 'alpha_reservedWord' || 
00087                     ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'OFFSET'))) { 
00088                     $i++; 
00089                 }
00090 
00091                 // Add remaining parts
00092                 while ($i < $parsed_sql['len']) {
00093                     $sql_query .= $parsed_sql[$i]['data'] . ' ';
00094                     $i++;
00095                 }
00096                 break;
00097             }
00098         }
00099     }
00100     $message = $GLOBALS['strSuccess'];
00101 }
00102 
00106 require('./tbl_properties_links.php');
00107 
00108 $export_type = 'table';
00109 require_once('./libraries/display_export.lib.php');
00110 
00111 
00115 require_once('./footer.inc.php');
00116 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6