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

Re: GT::SQL::Sets -- Need Some Help

Quote Reply
Re: GT::SQL::Sets -- Need Some Help In reply to
Okay, so that's a bad example, I suppose, because one could do something like that this way:

Code:
SELECT
Category.ID, Category.Name, Links.*
FROM
Links, CatLinks, Category
WHERE
Links.ID = CatLinks.LinkID
AND
CatLinks.CategoryID = Category.ID
AND
(
Category.ID IN (1,2,3)
OR
Category.FatherID IN (1,2,3)
)
AND
Category.ID != 4
or if using SQL::Condition, something like:

Code:
$condition = GT::SQL::Condition->new(
'Category.ID', 'IN', \"(1,2,3)",
'Category.FatherID', 'IN', \"(1,2,3)",
'Category.ID', '!=', 4,
);
$table = GT::SQL->table('Links','CatLinks','Category');
@results = @{$table->select($condition,['Category.ID', 'Category.Name', 'Links.*'])->fetchall_hashref};
But my previous question is still a valid one as you should still be able to do it with SQL::Sets::subtract somehow, it would just be a lot slower.

I just can't figure out what tpyes of parameters it is expecting:

Code:
sub subtract {
#-------------------------------------------------------------------------------
# takes two sets, A and B, and subtracts B from A. results enter current set
#
my $self = shift;
my $key = shift or return;
my $seta = shift or return;
my $setb = shift or return;
Are $seta, and $setb GT::SQL::Table objects, or are they other GT::SQL::Set objects?

They almost have to be other Sets, with $key being a primary key type of column in each set.

If so, then how does set A and B get filled with data to begin with so that they can be compared..?

Maybe I'm losing my place somewhere and the answer is some methods in the base class?

Thanks for any help which you are willing to provide.

-Steven
Subject Author Views Date
Thread GT::SQL::Sets -- Need Some Help shetland 3956 Jun 10, 2001, 5:27 AM
Thread Re: GT::SQL::Sets -- Need Some Help
Alex 3874 Jun 11, 2001, 3:16 PM
Thread Re: GT::SQL::Sets -- Need Some Help
shetland 3859 Jun 11, 2001, 4:57 PM
Thread Re: GT::SQL::Sets -- Need Some Help
shetland 3843 Jun 12, 2001, 10:42 AM
Post Re: GT::SQL::Sets -- Need Some Help
kitsune 3793 Jun 18, 2001, 3:56 PM