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

Update statement problems

Quote Reply
Update statement problems
I have a sub which select 2 values from the user table changes the values
then does an update to return the changed values to the table.

This was working. I rebooted my machine now it is not working.

These 2 select statements bring return the right values.
my $current_rating = $ut->select(['DP_ImageRating'],{ Username => $cand_user })->fetchrow_array;
my $votes = $ut->select(['DP_ImageVotes'],{ Username => $cand_user })->fetchrow_array;

Then I display the values to the screen and run some math on the values then perform this update statement:

$ut->update( {DP_ImageRating => $new_average,
DP_ImageVotes => $votes},
{ Username => $cand_user});

The update does not update the values.

I tried removing the plugin...which delete the columns from the table. Resyncing the database. Reinstalling.

No joy.

I also tried:
echo > lsql_Users.def

then resyncing..... this fixed the last update problem I had... no joy.
The irritating thing is I can update all the other fields in the table.

Any ideas would be appreciated.

Gordon
=================
www.iuni.com - Custom Coding and Plugins
YouPlusMe.com - For a good time
Quote Reply
Re: [gsm] Update statement problems In reply to
Code:
my $current_rating = $ut->select(['DP_ImageRating'],{ Username => $cand_user })->fetchrow_array;
my $votes = $ut->select(['DP_ImageVotes'],{ Username => $cand_user })->fetchrow_array;

You should be using one select query for that.

Code:
my ($current_rating, $votes) = $ut->select({Username => $cand_user }, ['DP_ImageRating','DP_ImageVotes'])->fetchrow;

Have you verified all the values of $cand_user, $new_average and $votes to make sure they are as you expect?

The only other thing I can suggest is to turn on debugging.

Last edited by:

Paul: Nov 18, 2002, 2:38 AM
Quote Reply
Re: [Paul] Update statement problems In reply to
I split the select to see if it was a problem with just one field .

the original was this:

#$ut->update( {DP_ImageRating => $new_average,
# DP_ImageVotes => $votes},
# { Username => $cand_user});

The select grab the right figures ... I have them appearing as tags in the page.
$cand_user comes from a previous page which is selected from the user table.

I went to the point of removing the user table and having links recreate it.
The funny thing is I have other update statements in the same cgi which act on different columns and they seem to work.
=================
www.iuni.com - Custom Coding and Plugins
YouPlusMe.com - For a good time
Quote Reply
Re: [gsm] Update statement problems In reply to
You'll need to turn on debugging and check your error log - it will tell you if anything went wrong.
Quote Reply
Re: [Paul] Update statement problems In reply to
I did this and the page times out (with debuging set to 1) after 10 minutes.... it displays every line up to the 2 before the update... ie up to the last select statement.

I tried putting fixed values in... same problem. I moved the code to the of the sub... before the select and inserted fixed values as below:

$ut->update( {DP_ImageRating => 10,
DP_ImageVotes => 1000},
{ Username => $cand_user});

And this updates ok.... but the one below does not.... I put different values in it.
=================
www.iuni.com - Custom Coding and Plugins
YouPlusMe.com - For a good time
Quote Reply
Re: [gsm] Update statement problems In reply to
I put the code back to the original... and ran the code 10 times with the same values..
On the eighth run through it did the update.


Crazy
=================
www.iuni.com - Custom Coding and Plugins
YouPlusMe.com - For a good time
Quote Reply
Re: [gsm] Update statement problems In reply to
I tried with a different dummy user and it updates every time.

I tried a number of times with 5 different dummy users 1 works every time 2 periodically and the others don't update.

stranger and stranger.
=================
www.iuni.com - Custom Coding and Plugins
YouPlusMe.com - For a good time
Quote Reply
Re: [gsm] Update statement problems In reply to
I've given up on using the user table.

I created a separate table for the values.

I guess this is probably a better way of doing it anyway.

Gordon
=================
www.iuni.com - Custom Coding and Plugins
YouPlusMe.com - For a good time