Hi,
I have a table ‘cmd’ containing 3 fields ‘validation’ (ENUM ‘Y’, ‘N’), ‘user_validation’ (INT) and ‘validation_date’ (DATETIME);
I’ve created a view ‘vv_cmd’ which is a “SELECT * FROM cmd”;
In PHPMaker 2022 I use this code in Row_Updating Server Event of ‘vv_cmd’ view :
// Row Updating event
function Row_Updating($rsold, &$rsnew)
{
// Enter your code here
// To cancel, set return value to false
if($rsold['validation'] != $rsnew['validation'] && $rsnew['validation'] == 'Y' ){
$rsnew['user_validation'] = CurrentUserID();
$rsnew['validation_date'] = CurrentDateTime();
} else {
$rsnew['user_validation'] = NULL;
$rsnew['validation_date'] = NULL;
}
return true;
}
I want to update ‘user_validation’ and ‘validation_date’ when ‘validation’ changes to ‘Y’ but it don’t works with this code.
Can someone help me please to check what’s wrong ?
You should enable Debug and check if there are SQL errors during update, enable:
Log SQL to file
Log error to file
Then both will be logged in the log file, check the log file for debug info, post the content for discussion.In your debug code (in the server event), your should check the data in $rsnew after your code also, e.g.
var_dump($rsold, $rsnew, $rsold['validation'] != $rsnew['validation'] && $rsnew['validation'] == 'Y'); // Before your code
// your code
var_dump($rsnew); // Check if your code did update $rsnew as you expected
die();