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

SQL Commands in nph-build.cgi

Quote Reply
SQL Commands in nph-build.cgi
Hi-

I can run the following two commands in SQL monitor in order to determine the users that have no links. I use a custom field in the Users table called 'Has_Links'

(1) Initialize Has_Links to 'No'

UPDATE lsql_Users
SET Has_Links = 'No'

(2) Set Has_Links to 'Yes' where the user has at least one link:

UPDATE lsql_Users, lsql_Links
SET lsql_Users.Has_Links = 'Yes'
WHERE lsql_Users.Username = lsql_Links.LinkOwner

That works fine in SQL Monitor. Now, I need to get this to run automatically whenever I run nph-build.cgi. I tried the following code, but it didn't work:

$DB->table('Users')->update ( { User_Has_Links => 'No' });

$links_condition = GT::SQL::Condition->new ('Users.Username', '=', 'Links.LinkOwner');

$DB->table({'Users','Links'})->update ( { Users.User_Has_Links => 'Yes' },$links_condition);

I guess this is probably because I'm trying to designate two tables on the last line, and am not doing it right, or maybe I have a problem with the condition? I'm not sure... Does anyone see how this could be written to work on nph-build.cgi?

--Frank
Subject Author Views Date
Thread SQL Commands in nph-build.cgi FrankM 2470 Nov 22, 2004, 5:34 PM
Post Re: [FrankM] SQL Commands in nph-build.cgi
Andy 2386 Nov 22, 2004, 11:58 PM
Thread Re: [FrankM] SQL Commands in nph-build.cgi
afinlr 2370 Nov 23, 2004, 6:31 AM
Post Re: [afinlr] SQL Commands in nph-build.cgi
FrankM 2345 Nov 24, 2004, 9:56 AM