home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / parse_analyze.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  1.8 KB  |  60 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: parse_analyze.lib.php 11326 2008-06-17 21:32:48Z lem9 $
  6.  */
  7. if (! defined('PHPMYADMIN')) {
  8.     exit;
  9. }
  10.  
  11. /**
  12.  *
  13.  */
  14. $GLOBALS['unparsed_sql'] = $sql_query;
  15. $parsed_sql = PMA_SQP_parse($sql_query);
  16. $analyzed_sql = PMA_SQP_analyze($parsed_sql);
  17.  
  18. // lem9: for bug 780516: now that we use case insensitive preg_match
  19. // or flags from the analyser, do not put back the reformatted query
  20. // into $sql_query, to make this kind of query work without
  21. // capitalizing keywords:
  22. //
  23. // CREATE TABLE SG_Persons (
  24. //  id int(10) unsigned NOT NULL auto_increment,
  25. //  first varchar(64) NOT NULL default '',
  26. //  PRIMARY KEY  (`id`)
  27. // )
  28.  
  29. // check for a real SELECT ... FROM
  30. $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
  31.  
  32. // If the query is a Select, extract the db and table names and modify
  33. // $db and $table, to have correct page headers, links and left frame.
  34. // db and table name may be enclosed with backquotes, db is optionnal,
  35. // query may contain aliases.
  36.  
  37. /**
  38.  * @todo if there are more than one table name in the Select:
  39.  * - do not extract the first table name
  40.  * - do not show a table name in the page header
  41.  * - do not display the sub-pages links)
  42.  */
  43. if ($is_select) {
  44.     $prev_db = $db;
  45.     if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
  46.         $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
  47.     }
  48.     if (isset($analyzed_sql[0]['table_ref'][0]['db'])
  49.       && strlen($analyzed_sql[0]['table_ref'][0]['db'])) {
  50.         $db    = $analyzed_sql[0]['table_ref'][0]['db'];
  51.     } else {
  52.         $db = $prev_db;
  53.     }
  54.     // Nijel: don't change reload, if we already decided to reload in import
  55.     if (empty($reload)) {
  56.         $reload  = ($db == $prev_db) ? 0 : 1;
  57.     }
  58. }
  59. ?>
  60.