-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtab_blood_test_exams_save.php
51 lines (38 loc) · 1.53 KB
/
tab_blood_test_exams_save.php
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
51
<?php
@session_start();
if (!isset($_SESSION["id"])) {
echo json_encode(null);
exit ;
}
if (!isset($_POST['blood_test_id']) || !isset($_POST['exam_type_id']) || !isset($_POST['exam_value']) || !isset($_POST['comments'])){
echo "error010101010";
return;
}
//DB
require_once ('general.php');
$db = new dbase();
$db->connect_sqlite();
if(isset($_POST['blood_test_examsFORM_updateID']) && !empty($_POST['blood_test_examsFORM_updateID']))
{
$sql = "UPDATE blood_test_exams set blood_test_id=:blood_test_id, exam_type_id=:exam_type_id, exam_value=:exam_value, comments=:comments where blood_test_exam_id=:blood_test_exam_id";
$stmt = $db->getConnection()->prepare($sql);
$stmt->bindValue(':blood_test_exam_id' , $_POST['blood_test_examsFORM_updateID']);
}
else
{
//check with the same exam type exist for the current blood test
$d = $db->getScalar("select count(blood_test_exam_id) from blood_test_exams where blood_test_id=? and exam_type_id=?", array($_POST['blood_test_id'], $_POST['exam_type_id'] ));
if ($d>0) {
echo "Duplicate examination type";
exit;
}
$sql = "INSERT INTO blood_test_exams (blood_test_id, exam_type_id, exam_value, comments) VALUES (:blood_test_id, :exam_type_id, :exam_value, :comments)";
$stmt = $db->getConnection()->prepare($sql);
}
$stmt->bindValue(':blood_test_id' , $_POST['blood_test_id']);
$stmt->bindValue(':exam_type_id' , $_POST['exam_type_id']);
$stmt->bindValue(':exam_value' , $_POST['exam_value']);
$stmt->bindValue(':comments' , $_POST['comments']);
$stmt->execute();
echo $stmt->errorCode();
?>