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

use of or in $links->select

Quote Reply
use of or in $links->select
hi,

i select a list of links from the database using gossamers way to select links:

@new = $links->select('ID', { isValidated => 'Yes', Lizenz => 'Shareware' })->fetchall_list;

but i want to select links with OR operator by the following (not working) example:

@new = $links->select('ID', { isValidated => 'Yes', Lizenz => 'Shareware' or Lizenz => 'Commercial' })->fetchall_list;

How can I do this?

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] use of or in $links->select In reply to
The below code should work :)

Code:
my $cond = GT::SQL::Conditions->new('isValidated','=','Yes','Lizenz','=','Shareware','Lizenz','=','Commercial');
@new = $links->select('ID', $cond )->fetchall_list;

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: Jan 31, 2004, 10:35 AM
Quote Reply
Re: [Andy] use of or in $links->select In reply to
hello andy,

thanks but when I use it, I've get the following error:

A fatal error has occured:
Can't locate object method "new" via package "GT::SQL::Conditions" at (eval 5) line 11.

Please enable debugging in setup for more details.

So I use also (find in another script):
my $cond = ($links->select GT::SQL::Conditions->new('isValidated','=','Yes','Lizenz','=','Shareware','Lizenz','=','Commercial'));
@new = $links->select('ID', $cond )->fetchall_list;
And get the error: unable to compile sub_name

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] use of or in $links->select In reply to
Try this:

my $cond = GT::SQL::Condition->new('Lizenz','=','Shareware','Lizenz','=','Commercial');
$cond->bool('or');
my $cond2 = GT::SQL::Condition->new($cond,'isValidated','=','Yes');
@new = $links->select('ID', $cond2 )->fetchall_list;

Last edited by:

afinlr: Jan 31, 2004, 3:32 PM
Quote Reply
Re: [afinlr] use of or in $links->select In reply to
Thank you!

This works in a Global and also in a seperate cgi script.

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] use of or in $links->select In reply to
Sorry, I didn't realise you were using it in a script. If using this in a script, you need to also add;

Code:
use GT::SQL::Condition;

...near the top of the script. If you are using it in a global, then LinksSQL includes this module for you :)

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] use of or in $links->select In reply to
Thanks Andy.

With the code from afinIr I dont use use GT::SQL::Condition;in the cgi script or in the global.

Best regards from
Bremen/Germany

Lothar