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

Getting an update in GTCOM to update Links, too.

Quote Reply
Getting an update in GTCOM to update Links, too.
Hi:

Been playing with something for a while, and I finally figured out what the problem is... so now I need a work around to make it work.

I would LIKE it so that when someone updated their profile in GTCom, it also updates the profile in Links. I THOUGHT ir was easy, just a:

my $user_db = $DB->table('Users');

$user_db->update ( {

Email => $user->{comm_email}

}, { Username => $user }) or die "Can't Update: $GT::SQL::error";

Inside the GTCom code.

Now I realize that since there us no User.def table definition native to GTCom, I cannot use this nice, easy way to update the User table.

How can I work around this? Should I dummy up a User.edf table for GTCom... or can I somehow add a regular SQL statement (that will not care if there is a def file or not!) to get this done?

Bottom line: how do I get one program to update a table from another program?>

Thanks!

dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
In the past 3-4 weeks, there was a thread on how to update tables in two different databases, that might help you.

check out this thread http://www.gossamer-threads.com/...orum.cgi?post=220496


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Getting an update in GTCOM to update Links, too. In reply to
Thanks Pugdog- I missed that one! Wink
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
OK, I followed the connect advice in that post, and came up with this:

use GT::SQL;
my $other_db = GT::SQL->new('/hd2/web/c/cartoon/public_html/bcdb/admin/defs');
my $user_db = $other_db->table('Users');

$user_db->update ( {
Email => $user->{comm_email},
Location => $user->{prof_location},
Occupation => $user->{prof_occupation},
Website => $user->{prof_website}

}, { Username => $user }) or die "Can't Update: $GT::SQL::error";



what this (should) do, is that when GTComm user feilds are updated, the corresponding fields in Links will be updated. At least, that is my hope. The script (Community::WEb::User.pm sub user_profile) I hope id the right one!

Oh, I should mention that the script seems to run just fine with this code in oit- the script does not halt, and gtcom is updated when a user edit's their profile.... I just cannot get Links fields updated!
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: Apr 30, 2003, 11:16 AM
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
You seem to be using $user as a hashref so I think that Username => $user must be wrong - should it be Username => $user->{Username}?
Quote Reply
Re: [afinlr] Getting an update in GTCOM to update Links, too. In reply to
afinlr:

OK, I feel silly now! Yep- that was it. Except the reference is:

$user->{comm_username}

Substitute that, and it works GREAT!

Thanks for the help!


dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
Whoo Hooo!

OK, I now have GTComm set up as the "Master" for users to edit their profiles, and have eliminated the Links user profile editor. Now GTCom will update the Links User table with any edited fields!

It takes some coding right now- there is no "plug-In" sytem for GTComm- but I think this is coming in the next (or final) versions. When plug-ins are available, I will code this into a plug in (if it is not made a part of GTComm).

In the meantime, if anyone needs the code, I will be happy to share! Wink
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
OK, I guess I got a BIT over anxious! The code works just GREAT with Links, but when I copied it over to also update Forum, I ran into a problem. I am getting

Can't call method "table" on an undefined value at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 349.

Here is the full code (note I commented out the Forum part, as that is causing the rror)

use GT::SQL;

use lib '/hd2/web/c/cartoon/public_html/bcdb/admin';
my $other_db = new GT::SQL '/hd2/web/c/cartoon/public_html/bcdb/admin/defs';
my $user_db = $other_db->table ('Users');

$user_db->update ( {
Email => $user->{comm_email},
Location => $user->{prof_location},
Occupation => $user->{prof_occupation},
Website => $user->{prof_website}
}, { Username => $user->{comm_username} }) or die "Can't Update: $GT::SQL::error";

# use lib '/hd2/web/f/forum/public_html/forum/admin';

# my $other_db1 = new GT::SQL '/hd2/web/f/forum/public_html/forum/admin/defs';
# my $user_db1 = $other_db1->table ('User');
# $user_db1->update ( {
# user_email => $user->{comm_email},
# user_location => $user->{prof_location},
# user_occupation => $user->{prof_occupation},
# user_homepage => $user->{prof_website}
# }, { user_username => $user->{comm_username} });

The code DOES update the Forum User information, but then gives the ugly ewrror page. Not sure why... anyone got any ideas why Forum would ast different in this regard than Links?

Thanks!

dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
"use" is executed at compile time, so those two "use lib" lines you have will both compile at the same time and hence one will overwrite the other. You need to use "require" which is executed at runtime.

require lib;
lib->import('/path/to/lib');

That *should* work.

For the full error you should turn on debugging and run the code again - you'll get a nice error message.

Last edited by:

Paul: May 1, 2003, 10:06 AM
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Thanks Paul...

Still a BIT confused. Do I put both paths in one statement like this:

lib->import('/hd2/web/c/cartoon/public_html/bcdb/admin', '/hd2/web/f/forum/public_html/forum/admin');

or two seperate statements like this:

use GT::SQL;
require lib;

lib->import('/hd2/web/c/cartoon/public_html/bcdb/admin');
my $other_db = new GT::SQL '/hd2/web/c/cartoon/public_html/bcdb/admin/defs';
... first code update Links...

require lib;

lib->import('/hd2/web/f/forum/public_html/forum/admin');

my $other_db1 = new GT::SQL '/hd2/web/f/forum/public_html/forum/admin/defs';
... second code update Forum...



I tried both,neither seemed to work...


dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
Can you go back to the original code and paste the full error into a post.
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Paul:

Full error. If you want more detaiul, do I set higher error settings for Forum or GTCOM?

Fatal Error: Can't call method "table" on an undefined value at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 349.

Stack Trace: GT::Base (47506): main::fatal called at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 349 with arguments (Can't call method "table" on an undefined value at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 349. ).GT::Base (47506): GForum::Table::User::_plg_update called at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 224 with arguments (GForum::Table::User=HASH(0x8643360), HASH(0x83f03b4), HASH(0x86430c0)).GT::Base (47506): GForum::Table::User::__ANON__ called at /hd2/web/c/cartoon/public_html/bcdb/admin/GT/Plugins.pm line 108 with arguments (GForum::Table::User=HASH(0x8643360), HASH(0x83f03b4), HASH(0x86430c0)).GT::Base (47506): GT::Plugins::dispatch called at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 224 with arguments (GT::Plugins, /Plugins/GForum, update_user, CODE(0x87563b4), GForum::Table::User=HASH(0x8643360), HASH(0x83f03b4), HASH(0x86430c0)).GT::Base (47506): GForum::Table::User::update called at /hd2/web/f/forum/private/lib/Community/Web/User.pm line 670 with arguments (GForum::Table::User=HASH(0x8643360), HASH(0x83f03b4), HASH(0x86430c0)).GT::Base (47506): Community::Web::User::user_profile called at /hd2/web/f/forum/private/lib/Community/Web/User.pm line 39 with no arguments.GT::Base (47506): Community::Web::User::process called at /hd2/web/f/forum/public_html/comm/community.cgi line 40 with arguments (user_profile).GT::Base (47506): main::main called at /hd2/web/f/forum/public_html/comm/community.cgi line 27 with no arguments.
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
There should be more to that error further down.
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Paul:

I just ran it again... and that is all of it (I swear!) :)

I went back in and set debug level to ten, and to NOT strip any sensitive info...

And it was still JUST the message above...

Shouold I set a higher error message in FORUM?
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
One should be fine. Below the stack trace is normally more info regarding the Links SQL library version but there should also be an error from $GT::SQL::error
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Weird...

I went in and changed debug level in Comm and Forum to 1, and then I added "or die "Can't Update: $GT::SQL::error";" to the end of the forum update code...

Still, just the above error message...

Tried some other combo's, too... nothing different...

HOWEVER, I got this from the error log on the server!

GT::SQL::Driver::MYSQL::sth (48593): OBJECT DESTROYED at /hd2/web/f/forum/private/lib/GT/SQL/Driver.pm line 701.

(48593) Community::comm_auth: session 'ec57a2e43a7d588b64aef3869824604e' authenticated

GT::SQL::Table (48593): Query: UPDATE comm_users SET prof_interests = ? , comm_tmp_pass = ? , comm_lastlogin = ? , prof_location = ? , comm_enabled = ? , prof_website = ? , prof_company = ? , comm_answer = ? , prof_first_name = ? , prof_country = ? , comm_email_redir = ? , app_BCDB = ? , comm_login_count = ? , comm_email_code = ? , prof_last_name = ? , comm_created = ? , comm_email_count = ? , comm_email_tmp = ? , comm_password = ? , comm_email_val = ? , comm_email = ? , comm_question = ? , prof_occupation = ? , comm_clr_pass = ? , app_Forum = ? , prof_gender = ? , prof_phone = ? , comm_username = ? , app_Forum_user_id = ? , comm_tmp_pass_valid = ? WHERE comm_id = ?

GT::SQL::Driver::MYSQL (48593): Preparing query: UPDATE comm_users SET prof_interests = ? , comm_tmp_pass = ? , comm_lastlogin = ? , prof_location = ? , comm_enabled = ? , prof_website = ? , prof_company = ? , comm_answer = ? , prof_first_name = ? , prof_country = ? , comm_email_redir = ? , app_BCDB = ? , comm_login_count = ? , comm_email_code = ? , prof_last_name = ? , comm_created = ? , comm_email_count = ? , comm_email_tmp = ? , comm_password = ? , comm_email_val = ? , comm_email = ? , comm_question = ? , prof_occupation = ? , comm_clr_pass = ? , app_Forum = ? , prof_gender = ? , prof_phone = ? , comm_username = ? , app_Forum_user_id = ? , comm_tmp_pass_valid = ? WHERE comm_id = ? at /hd2/web/f/forum/private/lib/GT/SQL/Driver/MYSQL.pm line 35.

GT::SQL::Driver::MYSQL (48593): Creating GT::SQL::Driver::MYSQL::sth object at /hd2/web/f/forum/private/lib/GT/SQL/Driver/MYSQL.pm line 38.

GT::SQL::Driver::MYSQL::sth (48593): OBJECT CREATED at /hd2/web/f/forum/private/lib/GT/SQL/Driver.pm line 569.

GT::SQL::Driver::MYSQL::sth (48593): Executing query: UPDATE comm_users SET prof_interests = '' , comm_tmp_pass = NULL , comm_lastlogin = 1051815684 , prof_location = 'slc ut' , comm_enabled = 1 , prof_website = 'tori' , prof_company = '' , comm_answer = 'erter' , prof_first_name = 'rettre' , prof_country = 'United States' , comm_email_redir = '' , app_BCDB = 0 , comm_login_count = 8 , comm_email_code = '' , prof_last_name = 'retret' , comm_created = 1051585721 , comm_email_count = 1 , comm_email_tmp = '' , comm_password = 'PrzBKhRtV7CXE' , comm_email_val = 1 , comm_email = 'test1@cartoon-factory.com' , comm_question = 1 , prof_occupation = 'junk 123' , comm_clr_pass = NULL , app_Forum = 1 , prof_gender = 1 , prof_phone = '' , comm_username = 'test1' , app_Forum_user_id = 2331 , comm_tmp_pass_valid = NULL WHERE comm_id = 9426

GT::Base (48593): GT::SQL::Driver::MYSQL::sth::execute called at /hd2/web/f/forum/private/lib/GT/SQL/Table.pm line 950 with arguments

(GT::SQL::Driver::MYSQL::sth=HASH(0x83dacb4), , [undef], 1051815684, slc ut, 1, tori, , erter, rettre, United States, , 0, 8, , retret, 1051585721, 1, , PrzBKhRtV7CXE, 1, test1@cartoon-factory.com, 1, junk 123, [undef], 1, 1, , test1, 2331, [undef], 9426).

GT::Base (48593): GT::SQL::Table::do_query called at /hd2/web/f/forum/private/lib/GT/SQL/Table.pm line 538 with arguments

(GT::SQL::Table=HASH(0x82503b4), UPDATE comm_users SET prof_interests = ? , comm_tmp_pass = ? , comm_lastlogin = ? , prof_location = ? , comm_enabled = ? , prof_website = ? , prof_company = ? , comm_answer = ? , prof_first_name = ? , prof_country = ? , comm_email_redir = ? , app_BCDB = ? , comm_login_count = ? , comm_email_code = ? , prof_last_name = ? , comm_created = ? , comm_email_count = ? , comm_email_tmp = ? , comm_password = ? , comm_email_val = ? , comm_email = ? , comm_question = ? , prof_occupation = ? , comm_clr_pass = ? , app_Forum = ? , prof_gender = ? , prof_phone = ? , comm_username = ? , app_Forum_user_id = ? , comm_tmp_pass_valid = ? WHERE comm_id = ?, ARRAY(0x84456a0)).

GT::Base (48593): GT::SQL::Table::update called at GT::SQL::Table::modify line 444 with arguments

(GT::SQL::Table=HASH(0x82503b4), HASH(0x8699288), HASH(0x872506c)).

GT::Base (48593): GT::SQL::Table::modify called at /hd2/web/f/forum/private/lib/Community/Web/User.pm line 647 with arguments

(GT::SQL::Table=HASH(0x82503b4), HASH(0x8445e7c)).

GT::Base (48593): Community::Web::User::user_profile called at /hd2/web/f/forum/private/lib/Community/Web/User.pm line 39 with no arguments.

GT::Base (48593): Community::Web::User::process called at /hd2/web/f/forum/public_html/comm/community.cgi line 40 with arguments

(user_profile).

GT::Base (48593): main::main called at /hd2/web/f/forum/public_html/comm/community.cgi line 27 with no arguments.

dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
Do you have a URL I could look at?
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Paul:

Happy to- what would you like to see? The error, the log in or something else?

I have the error currently disabled, too, so if you DO want that, let me know to put up the BAD code!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
Yeah the URL with the error and debugging would be great.
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Paul:

Sorry- ran into a snag.

OK, go to http://forum.bcdb.com/comm/community.cgi and log in as "xxxx" and the password is your name. (all lower case, I think)

From there, edit your profile, the error comes when you try to make a change.
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: May 1, 2003, 1:11 PM
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
Hmm I see. It's a community debugging message that doesn't seem to include the details that Links SQL/GForum do :(

Basically the error means that the database object is not being created properly. Underneath the code where you create the new object try adding:

die $GT::SQL::error;
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Paul:

I added die $GT::SQL::error; on a line by itself just beneath all my "new" code... it does not add anything to the error!

BTW, you can change fiels and all if you want, it is a test username...

Also, please note that it DOES update the Links and Forum User DB's BEFORE it errors out... (You will see when you go back I put in your name for a field.... that now shoews oon the Forum profole!)
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
Paul:

Playing around, I just discovered something weird. When I remove the coide to update forum it runs fine. When I remove the code to update Links, JUST the forum code still fails...

I am keying the Forum update based on the Username- could that be the problem? Should I key it on the Forum User ID? Is something else wird required to update the forum User table?
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Getting an update in GTCOM to update Links, too. In reply to
The error is before that point. GT::SQL->new is failing to create a database object and so when you call $object->table then $object doesn't exist, hence the error saying "Can't call method table() on an undefined value"

The error should be stored in $GT::SQL::error - I'm not sure why it's not showing though :(
Quote Reply
Re: [Paul] Getting an update in GTCOM to update Links, too. In reply to
Weird... because it STILL updates the table! I always do it and change something, then check Forum and Links.... and the data always gets written!

Could the command be wrong? I have seen two different ways to write it... this is what I use:

new GT::SQL '/hd2/web/f/forum/public_html/forum/admin/defs'

but also

GT::SQL->new('/hd2/web/f/forum/public_html/forum/admin/defs')

also weird that I use the same structure for both parts.... and the links one works without a hitch, but the Forum one does not. Here is thew code again, as it is now: (Again, forum is commented out, so it will run!)

use GT::SQL;

# use lib '/hd2/web/c/cartoon/public_html/bcdb/admin';

# use lib '/hd2/web/f/forum/public_html/forum/admin';

require lib;

lib->import('/hd2/web/c/cartoon/public_html/bcdb/admin');

my $other_db = new GT::SQL '/hd2/web/c/cartoon/public_html/bcdb/admin/defs';

my $user_db = $other_db->table ('Users');

$user_db->update ( {

Email => $user->{comm_email},

Location => $user->{prof_location},

Occupation => $user->{prof_occupation},

Website => $user->{prof_website}

}, { Username => $user->{comm_username} }) or die "Can't Update: $GT::SQL::error";

# require lib;

# lib->import('/hd2/web/f/forum/public_html/forum/admin');

# my $other_db1 = new GT::SQL '/hd2/web/f/forum/public_html/forum/admin/defs';

# my $user_db1 = $other_db1->table ('User');

# $user_db1->update ( {

# user_email => $user->{comm_email},

# user_location => $user->{prof_location},

# user_occupation => $user->{prof_occupation},

# user_homepage => $user->{prof_website}

# }, { user_id => $user->{app_Forum_user_id} }) or die "Can't Update: $GT::SQL::error";

dave

Big Cartoon DataBase
Big Comic Book DataBase