Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Conditions global question

Quote Reply
Conditions global question
Hi
I need to insert to 2 conditions in a global with an "OR" sing so just one condition is need, now it use the 2 conditions. Who can I do it?
$cond->add(Title => Like => "%$temp%");
$cond->add(Description => Like => "%$temp%");
Quote Reply
Re: [nir] Conditions global question In reply to
Hi,

This should do it:

Code:
$cond->add(Title => Like => "%$temp%");
$cond->add(Description => Like => "%$temp%");
$cond->bool('OR');

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Conditions global question In reply to
Thanks Andy
I insert this code but form some reason the conditions are not work at all.
$cond->add(Title => Like => "%$ temp%" , 'isValidated','=','Yes');
$cond->add(Description => Like => "%$ temp%" , 'isValidated','=','Yes');
$cond->bool('OR');
Quote Reply
Re: [nir] Conditions global question In reply to
Hi,

You probably need something like:

Code:
my $cond1 = new GT::SQL::Condition;
my $cond2 = new GT::SQL::Condition;

$cond1->add(Title => Like => "%$ temp%" , 'isValidated','=','Yes');
$cond1->bool('OR');

$cond2->add(Description => Like => "%$ temp%" , 'isValidated','=','Yes');
$cond2->bool('OR');

my $sth = $DB->table('Links')->select( $cond, $cond2 ) || die $GT::SQL::error

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Conditions global question In reply to
Hi Andy
Thanks for your replay, for same reason the conditions are still not work. I change it to-
my $cond = new GT::SQL::Condition;
$cond->add(Title => Like => "%$temp%");
$cond->add(Description => Like => "%$temp%");
$cond->bool('OR');
and it work, thanks for give me a direction to solve it.
Quote Reply
Re: [Andy] Conditions global question In reply to
You can't just use "Like" without quotes!!
Quote Reply
Re: [Wychwood] Conditions global question In reply to
Erm, nir's post above your's kinda defies your last statement :P

Code:
$cond->add(Title => Like => "%$temp%");
$cond->add(Description => Like => "%$temp%");

..and he says:

nir wrote:
and it work, thanks for give me a direction to solve it.

I was actually only pasting it from his code he showed anyway - I don't normally use that format for conditions - prefer ('field','cond','val').

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates