saseow
Posts: 744
|
| Posted: 10/04/2008, 5:44 AM |
|
In the AfterExecuteInsert of an editable grid I have:
//Calculate the total_owned field
global $no_of_teams;
$SQL = "SELECT number_of_teams FROM league_setup WHERE user_id=".$UserId;
$db->query($SQL);
$no_of_teams = $db->f("number_of_teams");
$SQL= "UPDATE league_info SET total_owned = number_team * ".$no_of_teams." where user_id = ".$UserId;
$db->query($SQL);
$db->close();
I have tried everything from javascript to playing in the traffic. Please help someone!
Trevor
|
 |
 |
saseow
Posts: 744
|
| Posted: 10/04/2008, 8:24 AM |
|
The only solution I could find was to create a session variable of the 'number_of_teams'.
In the After Submit event I added:
$db = new clsDBhockey_stats();
$sql= "UPDATE league_info SET total_owned = number_team * ".CCGetSession("team_number");
$db->query($sql);
$db->close();
Why the other ways did not work I have no idea!
|
 |
 |
ColinA
Posts: 9
|
| Posted: 10/06/2008, 5:56 PM |
|
I don't think you can have two sql statements in one event. Possibly a security feature to prevent code injection?
_________________
Col |
 |
 |
Geoff Bomford
|
| Posted: 10/06/2008, 10:50 PM |
|
How are you setting $no_of_teams ? If from a $_Post then that value might be
lost when the form is re-loaded after the update. Using the session variable
probably preserves the value during the reload?
"saseow" <saseow@forum.codecharge> wrote in message
news:548e765370750d@news.codecharge.com...
> In the AfterExecuteInsert of an editable grid I have:
>
> //Calculate the total_owned field
> global $no_of_teams;
> $SQL = "SELECT number_of_teams FROM league_setup WHERE user_id=".$UserId;
> $db->query($SQL);
> $no_of_teams = $db->f("number_of_teams");
> $SQL= "UPDATE league_info SET total_owned = number_team *
> ".$no_of_teams."
> where user_id = ".$UserId;
> $db->query($SQL);
> $db->close();
>
> I have tried everything from javascript to playing in the traffic. Please
> help
> someone!
>
> Trevor
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
>
|
|
|
 |
saseow
Posts: 744
|
| Posted: 10/07/2008, 12:31 AM |
|
Hi Geoff,
I am setting the variable using DLookup and it seems to work perfectly.
Regards,
Trevor
|
 |
 |
datadoit
|
| Posted: 10/07/2008, 5:37 AM |
|
Here's what should work for you:
//Calculate the total_owned field
$db = new DBYourConnection();
$number_of_teams = CCDLookUp("number_of_teams", "league_setup",
"user_id=" . $db->ToSQL(CCGetUserID(),ccsInteger));
$db->close();
$db = new DBYourConnection();
$SQL = "UPDATE league_info SET total_owned = (number_team * " .
$number_of_teams . ") where user_id = " .
$db->ToSQL(CCGetUserID(),ccsInteger);
$db->query($SQL);
$db->close();
|
|
|
 |
saseow
Posts: 744
|
| Posted: 10/07/2008, 5:57 AM |
|
Hi Datadoit,
Thanks for the reply. As the session variable is working, I am going to leave it as is for now. I have stored your suggestion in my repository and will certainly look at it later. Right now I am working to a deadline and falling behind so don't have much time to experiment.
Thanks so much!
Regards,
Trevor
|
 |
 |