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

Editors Online: Table Join Prob

Quote Reply
Editors Online: Table Join Prob
Paul (or any of you SQL/perl experts!), I am in the midst of modifying your who's online script to show details of the editors categories, when the user online is an editor...

I am almost there, but I am not sure how to do a table join I get a list of category paths, and not category id's... (the script so far is actually working)

Code:


sub main {
#----------------------------------------------------------
# Show whos online with editor info.

my @sess = ();
my @online = ();
my $path = "/s/mysite.com/cgi-bin/admin/sessions";
my $sess = {};
my @editor_catid = ();
my $user =();

opendir (DIR, $path) or die "Can't read sessions : $path : $!";
@sess = grep { /^\w+$/ } readdir(DIR);
closedir DIR;

print "Content-type: text/html\n\n";

for (@sess) {
$sess = do("$path/$_");
$user = $sess->{username};
@editor_catid = $DB->table('Editors')->select(['CategoryID'],{Username => $user})->fetchall_list;
print "$user : @editor_catid<br>";
}

}








Code:


@editor_catid = $DB->table('Editors','Category')->select(['CategoryID'],{Username => $user})->fetchall_list; ??



http://www.iuni.com/...tware/web/index.html
Links Plugins

Last edited by:

sooke: May 17, 2002, 11:46 AM
Quote Reply
Re: [sooke] Editors Online: Table Join Prob In reply to
I guess what I am trying to say is:

@list = SELECT 'Full_Name" From Category Where (Category.ID=>Editors.CategoryID) AND ( Editors.User =>$user ) to return Category.Full_Name fetchall_list


My bad attempt ->

@editor_categories = $DB->table('Editors','Category')->select({'Category.ID'=>'EditorCategoryID'},{Username => $user}, ['Category.ID', 'Category.Full_Name'])->fetchall_list;




?Crazy



http://www.iuni.com/...tware/web/index.html
Links Plugins

Last edited by:

sooke: May 17, 2002, 1:11 PM
Quote Reply
Re: [Ian] Editors Online: Table Join Prob In reply to
Did you find a working solution to this ?


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Ian] Editors Online: Table Join Prob In reply to
>>
@list = SELECT 'Full_Name" From Category Where (Category.ID=>Editors.CategoryID) AND ( Editors.User =>$user ) to return Category.Full_Name fetchall_list
<<

Try:

Code:
my @list = $DB->table('Category', 'Editors')->select( { Username => $user }, 'Full_Name' )->fetchall_list || die $GT::SQL::error;

...otherwise try:

Code:
my @list = $DB->table('Category', 'Editors')->select( { ID => \'CategoryID', Username => $user }, 'Full_Name' )->fetchall_list || die $GT::SQL::error;

Thats a guess. I've added the die in to catch any screwups :)
Quote Reply
Re: [Paul] Editors Online: Table Join Prob In reply to
Thanks both guys!

I have this working, as messy as it is: (though it is nice to see better ways to do it, thanks Paul, I will tinker with your suggestion.)

Sorry about the woeful formatting, makes it hard to read, but it is fine inside my plug-inCrazy

Quote:


for (@sess) {
$sess = do("$path/$_");
$user = $sess->{username};
@editor_catid = $DB->table('Editors')->select(['CategoryID'],{Username => $user})->fetchall_list;
my $file = $path . "/" . $_;
my $modtime = localtime( (stat($file))[9] );
print "<b>$user</b> : ";
if ($editor_catid[0] > 0) {
print qq~<font size="2" color="#FF9900"><b><i>Editor</i></b></font>&nbsp;&nbsp;&nbsp;<small>($modtime)</small><br>~;
}
else {
print qq~<i>User</i>&nbsp;&nbsp;&nbsp;<small>($modtime)</small><br>~;
}
foreach $catid (@editor_catid) {
if ($catid > 0) {
my $cat = $DB->table('Category')->select( ['Full_Name'], { ID => $catid } )->fetchrow_array;
print qq~<font size="2" color="#333333">&nbsp;Category: $cat</font><br>~;
}
}


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Editors Online: Table Join Prob In reply to
Any possibility to release this plugin?
Quote Reply
Re: [chaos] Editors Online: Table Join Prob In reply to
I have emailed Alex about placing my Editor Monitor plug-in which includes features such as this. It is a commercial plug-in, but still quite cheapWink

See: http://www.gossamer-threads.com/...orum.cgi?post=198588

and the rest of this thread.


http://www.iuni.com/...tware/web/index.html
Links Plugins