I never got round to doing as discussed with the merging of buildIf into the new txtsql, truth be told I'm using this because I don't want to pay for sql liscences yet but will end up refactoring the code in the future to use it where needed.
I have come across my first bug/omission in your otherwise excellent code...
I was trying to get an WHERE clause with < or > (e.g. x <= 5) working but discovered that it is overridden with an == operator...
this is the problem code...
txtSQL.class.php
line 1160...
- Code: Select all
switch ( TRUE )
case strpos($value, '<='): $type = 2; $op = '<='; break;
case strpos($value, '>='): $type = 2; $op = '>='; break;
case strpos($value, '<' ): $type = 2; $op = '<'; break;
case strpos($value, '>' ): $type = 2; $op = '>'; break;
cause op type 2 for this group, which is then handled by...
line 1290...
- Code: Select all
switch ( $type )
case 1:
case 2: $quotes = ( !is_numeric($val) || $cols[rtrim($col)]['type'] != 'int' ) ? '"' : '';
$query .= ' ( '.$f1.'$value['.$position.']'.$f2.' '.( $op == '=' ? '==' : $op ).' '.$quotes.$val.$quotes.' ) ';
break;
and ( $op == '=' ? '==' : $op ) forces the op to be == which shouldn't happen
I have changed my code to work around it completely but I might suggest a fix along the following lines...
- Code: Select all
case strpos($value, '<='): $type = 0; $op = '<='; break;
case strpos($value, '>='): $type = 0; $op = '>='; break;
case strpos($value, '<' ): $type = 0; $op = '<'; break;
case strpos($value, '>' ): $type = 0; $op = '>'; break;
case 0: $quotes = ( !is_numeric($val) || $cols[rtrim($col)]['type'] != 'int' ) ? '"' : '';
$query .= ' ( '.$f1.'$value['.$position.']'.$f2.' '.$op.' '.$quotes.$val.$quotes.' ) ';
break;
Barry
