[RESOLVED] Update result value?
I have a bunch of data where I'm allowing people to mass-modify records.
Example:
Contract A - active
Contract B - active
Contract C - not active
The 'active' field is a select box and they can change one or all of them all at once. So then I have a simple update statement:
Code:
UPDATE DTCONTRACT SET active = 1 - active WHERE CONTRACT_ID = 'x' AND active != $val
$val = whatever they selected in the box.
But my dilemma is this: I have to have an audit trail for what was changed. So how do I check if that specific record actually got updated? I currently have this (and I apologize that it's in PHP but that's what it's written in... but the idea is generally the same):
Code:
foreach($_POST as $key => $val)
{
// UPDATE active status of contract
if(substr($key, 0, 7) == 'active_')
{
$query = "UPDATE DTCONTRACT SET active = 1 - active WHERE CONTRACT_ID = '" . substr($key,7) . "' AND active != $val";
$result = $ehandle->update_query($query);
if($result)
$tbox->log("Updated active status for contract: ".substr($key,7), substr($key,7));
}
}
But the result is always valid so it logs the change... so is there something I can check to see if the update was actually applied??
And yes, I know I need to use bind variables but I'm switching to Oracle in a few months and I'll do it once that happens.
Re: [RESOLVED] Update result value?
In all of my tables I have UPDATED_ON and UPDATED_BY fields. Each of my UPDATE/INSERT queries include those two fields so I not only know when that last time the record was updated, but I also know who did the updating (I grab the windows logon id)
Just a thought...
Re: [RESOLVED] Update result value?
Well considering that I refuse to force my users to use IE and I wouldn't dream of using .NET, I'm fine with pulling that info out of a LDAP table based on the login that they use.
Plus, you're also limiting your users to connecting to your application from a Windows, company-specific workstation. That's kind of a crappy way to handle things, IMHO.