Gossamer Forum
Home : Products : Gossamer Links : Discussions :

GT::SQL::Condition help

Quote Reply
GT::SQL::Condition help
hello

I want do something like:

y $cond_required = GT::SQL::Condition->new( ['ID', 'IN', \@cids], ['Payment_Mode', '=', '3'] );

this works fine, but when I add another Payment_Mode statement something like:

y $cond_required = GT::SQL::Condition->new( ['ID', 'IN', \@cids], ['Payment_Mode', '=', '3']], ['Payment_Mode', '=', '1'] );

it won't work,
are there any suggestions for it?
Quote Reply
Re: [ridesworld] GT::SQL::Condition help In reply to
I'm guessing the part in red was a typo?

Quote:
['Payment_Mode', '=', '3']],

You should also be able to do;

Code:
my $cond_required = GT::SQL::Condition->new( ['ID', 'IN', \@cids,'Payment_Mode', '=', '3', 'Payment_Mode', '=', '1'] );

..i.e all as one string.

Hope that helps.

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: [ridesworld] GT::SQL::Condition help In reply to
I assume that you want a condition where ID is in @cids AND (Payment Mode = 3 OR Payment Mode = 1)?

If so you'll want something like this I think:

my $cond1 = GT::SQL::Condition->new(Payment_Mode => '=' => '3', Payment_Mode => '=' => '1');
$cond1->bool('or');
$cond_required = GT::SQL::Condition->new( ID => 'IN' => \@cids, $cond1 );
Quote Reply
Re: [afinlr] GT::SQL::Condition help In reply to
>>>my $cond1 = GT::SQL::Condition->new(Payment_Mode => '=' => '3', Payment_Mode => '=' => '1'); <<<

I've never seen a format like that. Is it valid, or just a typo? :/

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] GT::SQL::Condition help In reply to
This is the way that GT recommends you use it in the new version - see the docs. Not sure why it was changed and the old way seems to work fine.
Quote Reply
Re: [afinlr] GT::SQL::Condition help In reply to
Hello afinlr,

The way you suggested works perfect.
The way andy suggested gives me the same problem I already had, namely selecting categories with other Payment_Mode values too on my selected list.

I don't want to have categories with Payment_Mode 1 (Not accepted) on my list.

Thanks for help.