From 7eaa1d3c64dce13ada611e3546b88993a332f331 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 13 Mar 2003 16:00:17 +0000 Subject: [PATCH] where_clause_identifiers --- libraries/sqlparser.lib.php3 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 623992f8b..3288cbf7f 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -647,6 +647,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { 'order_by_clause'=> '', 'having_clause' => '', 'where_clause' => '', + 'where_clause_identifiers' => array(), 'queryflags' => array(), 'select_expr' => array(), 'table_ref' => array() @@ -707,7 +708,11 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { * ['order_by_clause'] * ['having_clause'] * ['where_clause'] + * + * and the identifiers of the where clause are put into the array + * ['where_clause_identifier'] */ + // must be sorted // TODO: current logic checks for only one word, so I put only the // first word of the reserved expressions that end a table ref; @@ -1234,6 +1239,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { if ($upper_data == 'WHERE') { $in_where = TRUE; $where_clause = ''; + $where_clause_identifiers = array(); $seen_group = FALSE; $seen_order = FALSE; $in_group_by = FALSE; @@ -1292,6 +1298,13 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { } if ($in_where && $upper_data != 'WHERE') { $where_clause .= $arr[$i]['data'] . $sep; + + if (($arr[$i]['type'] == 'quote_backtick') + || ($arr[$i]['type'] == 'quote_double') + || ($arr[$i]['type'] == 'quote_single') + || ($arr[$i]['type'] == 'alpha_identifier')) { + $where_clause_identifiers[] = $arr[$i]['data']; + } } // clear $upper_data for next iteration @@ -1317,6 +1330,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { if (isset($where_clause)) { $subresult['where_clause'] = $where_clause; } + if (isset($where_clause_identifiers)) { + $subresult['where_clause_identifiers'] = $where_clause_identifiers; + } // They are naughty and didn't have a trailing semi-colon, @@ -1444,7 +1460,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { } for ($i = 0; $i < $arraysize; $i++) { - //DEBUG echo "" . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; + // DEBUG echo "" . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; $before = ''; $after = ''; $indent = 0;