Welcome
Welcome to <strong>txtSQL</strong>.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Greater Than / Less Than WHERE clause in txtsql 2.2 final

Post bugs here

Greater Than / Less Than WHERE clause in txtsql 2.2 final

Postby barry on Sun Jun 22, 2008 7:05 am

Hi man,

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
barry
 
Posts: 3
Joined: Mon Apr 21, 2008 7:14 am

Postby FarazAli on Mon Jun 23, 2008 8:52 am

I'm confused as to what you're problem is...

When you try to execute a 'WHERE' command (using for example, "x <= 5") then you get an error? Or is the wrong operator being placed in the PHP code?

Thanks
Latest txtSQL Stable Release: txtSQL 2.2 Final

Track 4.0 Development

Image
FarazAli
Site Admin
 
Posts: 73
Joined: Sun Mar 25, 2007 1:08 pm
Location: New Jersey, NJ

Re: Greater Than / Less Than WHERE clause in txtsql 2.2 final

Postby zzw08 on Tue Jul 14, 2009 5:33 am

http://www.fashion-products.com [url=http://www.fashion-products.com ]is a sell air force one,
air jordan,bape,kicks,nike,Jerseys,Shoes,Clothing,Bag,Glasses,Caps&Hats,sneakers,sunglasses,
watches,Jewelry,Electronics,NBA,NFL,NHL,MLB[/url]
shoes
clothing
Handbags Wallets
Hat
Sunglasses
Belts
Watches
Jewelry
zzw08
 
Posts: 53
Joined: Tue Jul 14, 2009 5:15 am


Return to Bugs

Who is online

Users browsing this forum: No registered users and 0 guests

cron