~hexmode/+junk/main

« back to all changes in this revision

Viewing changes to install-files/apps/phpmyadmin2.10.1/libraries/parse_analyze.lib.php

  • Committer: Mark A. Hershberger
  • Date: 2008-01-05 19:38:56 UTC
  • Revision ID: hershberger@spawn-xp-20080105193856-6rnzgwa4nehue3qj
initial commit

Show diffs side-by-side

added added

removed removed

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