1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| $db = new db_user2();
$sql = "SELECT pcr_results( :id_request,:id_group,:id_task,
:id_patient,:pcr_date,:failure,
:gag,:pol,:env,:hubg,
:type_sample)";
$id_request=0; $id_group=0; $id_task=0; $id_patient=0;
$pcr_date=''; $gag=''; $pol=''; $env=''; $hubg=''; $type_sample=0;
$db->beginTransaction();
$result = $db->prepare($sql);
$result->bindParam('id_request',$id_request,PDO::PARAM_INT);
$result->bindParam('id_group',$id_group,PDO::PARAM_INT);
$result->bindParam('id_task',$id_task,PDO::PARAM_INT);
$result->bindParam('id_patient',$id_patient,PDO::PARAM_INT);
$result->bindParam('pcr_date',$pcr_date,PDO::PARAM_STR);
$result->bindParam('gag',$gag,PDO::PARAM_STR);
$result->bindParam('pol',$pol,PDO::PARAM_STR);
$result->bindParam('env',$env,PDO::PARAM_STR);
$result->bindParam('hubg',$hubg,PDO::PARAM_);
$result->bindParam('type_sample',$type_sample,PDO::PARAM_INT);
foreach($_POST as $key => $value){
if(!preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\-([0-9]+)#([a-z_]+)$/',$key,$matches)) trigger_error("Please contact the admin[h]",E_USER_ERROR);
if($matches[5]==='failure'){ // nasty trick to take every entry only once
$prefix = $matches[1]."-".$matches[2]."-".$matches[3]."-".$matches[4];
if( empty($_POST[$prefix."#failure"])) $result->bindValue('failure',$_POST[$prefix."#failure"],PDO::PARAM_NULL);
else $result->bindValue('failure',$_POST[$prefix."#failure"],PDO::PARAM_INT);
$id_request = $matches[1];
$id_group = $matches[2];
$id_task = $matches[3];
$id_patient = $matches[4];
$pcr_date = $_POST[$prefix."#date"];
$gag = $_POST[$prefix."#gag"];
$pol = $_POST[$prefix."#pol"];
$env = $_POST[$prefix."#env"];
$hubg = $_POST[$prefix."#hubg"];
$type_sample = $_POST[$prefix."#type_sample"];
$result->execute();
} else continue;
}
if($db->commit()) echo "<meta http-equiv='refresh[..] |
Partager