Gossamer Forum
Home : Products : Gossamer Links : Discussions :

query_sth and adding a condition?

Quote Reply
query_sth and adding a condition?
Hi there,

Is it possible to add a condition to a line like this:
my $link_sth = $links->query_sth ($args);

This format seems to only allow us to pass a hash of args and nothing else. Is that correct? or is there a way to add a condition such as this:

my $cond = GT::SQL::Condition->new('ID', 'IN', \@ids);
$cond->bool('or') #where @ids is a list of links i'm sure are not going to appear otherwise.

to a $links->query_sth format?

Thanks for your help.

peace.
Quote Reply
Re: [klangan] query_sth and adding a condition? In reply to
Okay, i found we can use something called $args->{callback} = \&somevalidsubroutine

Is there another way?

peace.
Quote Reply
Re: [klangan] query_sth and adding a condition? In reply to
Hi,

Not really, no. You want to use ->select() in this case.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] query_sth and adding a condition? In reply to
Hi Alex,

Quote:
Not really, no. You want to use ->select() in this case.

Cheers,

Alex


hmm, interesting. May I then ask why you use $args->{callback} in the search script instead of select(). What makes that situation different?

peace.
Quote Reply
Re: [klangan] query_sth and adding a condition? In reply to
Hi,

Callback is a bit different. It lets you pass in a subroutine that will get a hash of primary key => score, and let you filter the results however you like. It's used to filter the search results within a category.

It's only used with a full text search (passing in query=something).

If you are doing a full text search, then it may be a good idea, but if you are doing a field search (i.e. col1 = x, col2 = y), then it won't work.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] query_sth and adding a condition? In reply to
Thanks Alex,

that clears it up. I have a table in the equivalent position of Reviews that I need to search on when I do a query search on Links. It works well. I did have to slightly rewrite and converto to a plugin Search::query so that I could plugin to the existing callback without losing the search category callback function.

anyway, thanks again for the clarification.

peace.