[Phpmyadmin-devel] SQL parser

Marc Delisle Delislma at CollegeSherbrooke.qc.ca
Mon Jul 22 13:52:12 CEST 2002


Robin Johnson wrote:

> On Mon, 22 Jul 2002, Div Loïc wrote:
> 
> 
>>Robin, I've just have had a look at the last
>>version of your parser. Here is some PHP3
>>problems i've noticed:
>>
>>- function must be declared before they are
>>  called. Then, for example, you can't call
>>  "PMA_sqlParser_ArrayAdd_Timer()" in the
>>  "PMA_sqlParser_ArrayAdd()" function because
>>  the former is declared after the latter;
>>
> How does one deal with recursive functions then ?
> PMA_sqlParser_isEscaped() used to be recursive, but I found it slightly
> faster as iterative (not that much).


I don't think this is a problem in PHP3: when you call a function from 
within itself, is has been declared at a higher point in the source.


> 
> 
>>- "include_once" and "require_once" are PHP4
>>  functions;
>>- "===" and "!==" are PHP4 operators.
>>
> How does one then properly evaluate some expressions?
> $f = FALSE;
> $g = 0
> 
> ($f == FALSE) -> true
> ($g == FALSE) -> true
> ($f === FALSE) -> true
> ($g === FALSE) -> false
> 
> My code relies on this difference, as some of the PHP functions (strpos
> namely) return FALSE for not found, and integers [0-strlen).
> 
> In that case, a 0 is the first position of the string, which is distinctly
> different from FALSE.


The is_integer() test will give false on $f and true on $g. Not funny 
but is works.
is_bool() in a PHP4 function.


> 
> One of your changes:
>  function PMA_sqlParser_strInStr($needle,$haystack)
>  {
> -    return (strpos($haystack,$needle) !== FALSE);
> -}
> +    return (strpos(' ' . $haystack, $needle) > 0);
> +} // end of the "PMA_sqlParser_strInStr()" function
> 
> Actually breaks the function, stopping it from recognizing some things.


It's a trick to avoid having a 0 in first position, but I guess
the is_integer() trick can be used.





-- 
Marc Delisle






More information about the Developers mailing list