Gossamer Forum
Quote Reply
BETWEEN in GT::SQL...
Hi,

I'm just working on an IP matching system for our site. We have a "dump" of the IP ranges, and need to use something like;

SELECT * FROM ip2location WHERE IP_NUMBER BETWEEN StartRange AND EndRange

..where IP_NUMBER is the binary value, i.e 3401190660.

Been having a play at trying to get this to work with GT::SQL, but havn't had any success so far.

Anyone got any ideas? Smile

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BETWEEN in GT::SQL... In reply to
Not sure, if GT::SQL supports BETWEEN. I should check the docs.

Try the do() method, where you can use full select statement.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] BETWEEN in GT::SQL... In reply to
Hi,

Ah, forgot about the do() feature <G>

This works a charm, for anyone who may be interested :)

my $result = $NEWDB->table('IP')->do("SELECT * FROM IP WHERE $overall BETWEEN StartRange AND EndRange")->fetchrow_hashref;

Thanks Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BETWEEN in GT::SQL... In reply to
Hi,

Alternatively:

my $cond = GT::SQL::Condition->new("Column", "BETWEEN", \"StartRange AND EndRange");
my $sth = $Table->select($cond);

You use \"" to ensure GT::SQL::Condition does not escape the value.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] BETWEEN in GT::SQL... In reply to
Aah.. very cool Cool

BTW, what are you doing working today!

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Dec 29, 2005, 1:50 AM