This topic is locked
[SOLVED]

 Prevent duplicate values - Condition

8/25/2015 5:09:50 PM
PHPRunner General questions
M
macalister author

Hello.
In earlier versions of PHPRunner I had to validate if some data already existed in the table(before record add - event). If duplicate records existed then the form dont save the data and sent an alert by email. Duplicate records were saved if a condition was satisfied in a field in a table (table.field_allowSaveDuplicateRecords = yes)
Example code:

//event before record add

$checkDuplicate = "select * from table where field = "'.$values["field"].'"";

$rsCheck = db_query($checkDuplicate,$conn);

$duplicateData=db_fetch_array($rsCheck);
if($duplicateData){
....send email alert
//check if the duplicate data is allow to save in the table
$checkCondition = "select field_allowSaveDuplicateRecords from table where field = "'.$values["field"].'"";

$rsCheckCondition = db_query($checkCondition,$conn);

$condition=db_fetch_array($rsCheck);
if($condition["field_allowSaveDuplicateRecords"] == "yes"){
return true;
}

else{



return false;
}

}


In PHPRunner 8 the feature "prevent duplicate data" is very interesting. But is possible remove that validation based on a condition like i described previously ?

Sergey Kornilov admin 8/25/2015

No, removing this condition in runtime is not possible. Your best option to perform all validation manually.

M
macalister author 8/25/2015

Ok, thanks for your quickly response and excelent support!