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
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