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