Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Link Properties MySQL Query Help

Quote Reply
Link Properties MySQL Query Help
I was wondering if someone knew how to fix this.

On our site we have about 300 categories in total. One of the link property we have for all listings is link_type (ENUM) and options for this are blue, green, yellow & white. Now all the listings are having blue as default, as this link property was added recently.

However within 19 specific categories (1 root category and are its 18 sub categories) all the links should be having ENUM field link_type to be set to 'white'. I also have category ID for root category and each of its sub categories.

It would be very much appreciated if someone can tell me on how to edit link_type (ENUM) values of all the listings within these categories all at once instead of having to edit each listing in there individually.

Thank you for the help.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Link Properties MySQL Query Help In reply to
~ anyone ~ ?

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Link Properties MySQL Query Help In reply to
I don't have time to write out the code at the moment (getting ready for work), but you want to use $DB->table("Category")->children($id_of_root_category) to get the categories. Then use the returned data to make a GT::SQL::Condition object with a 'ID => "IN" => $children' condition.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [SWDevil.Com] Link Properties MySQL Query Help In reply to
Code:
#!/usr/bin/perl

use strict;
use lib 'admin';
use GT::Base;
use Links qw/$IN $DB $CFG $USER/;

Links::init ('admin');
Links::init_user();

local $SIG{__DIE__} = \&Links::fatal;

# set value of $parent
my $parent = 2;
my $child = $DB->table("Category")->children($parent);

# uncommment next line to include parent category in mass update
# push @$child, $parent;

my $obj = GT::SQL::Condition->new(ID => 'IN' => $child);
my $ret = $DB->table("Category")->update({ link_type => 'blue' }, $obj) or die $!;

print $IN->header('text/plain');
print "categories updated successfully\n";

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Link Properties MySQL Query Help In reply to
hum.. I am not sure how to use this code? Do I just put this code into the textarea under SQL monitor (GLinks admin -> Database -> SQL Monitor) and execute Query?

Thank you for your help.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Link Properties MySQL Query Help In reply to
save it as a .cgi file, set execute permissions, and run it.

Philip
------------------
Limecat is not pleased.