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

FatherID and CategoryID together?

Quote Reply
FatherID and CategoryID together?
Ok so this global returns some links with the 2 specified father id's. How do I also specify an additional category not within the FatherID.

I tried something like:

Code:
$sth = $search_db->select ( { FatherID => [275, 44] }, {CategoryID => 163}, GT::SQL::Condition->new('isValidated', '=','Yes'));

but unfortunately dint return anything. Without the {CategoryID => 163} bit, it works fine.

Do I have the syntax incorrect?

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] FatherID and CategoryID together? In reply to
Hi,

Try adding this after $sth:

Code:
print $sth->query;

..so you can at least see what kinda query is being run :)

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: [Eraser] FatherID and CategoryID together? In reply to
I would say that's the incorrect query, since you're saying I want (I assume you're searching on the Category table), all categories with FatherID that are either 275 or 44 AND CategoryID that's 163. I'm guessing you're wanting to do either. In that case, you need a GT::SQL::Condition object to do what you want. Something like:

$DB->table('Category', 'Links', 'CatLinks')->select(GT::SQL::Condition->new(FatherID => 'IN' => [275, 44], CategoryID => '=' => 163, 'OR'), VIEWABLE);

That makes it an OR condition between the two FatherID and CategoryID constraints, and we want to use the VIEWABLE constant instead of just checking for isValidated because that takes payments into consideration as well (if enabled).

Adrian