-
Notifications
You must be signed in to change notification settings - Fork 1
/
getDivisiJoin.php
36 lines (29 loc) · 1 KB
/
getDivisiJoin.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
<?php
include_once('koneksi.php');
if (!empty($_GET['tukang_id'])) {
$tukang_id = $_GET['tukang_id'];
//$query = "SELECT * FROM pesanan JOIN divisi ON pesanan.tukang_id = divisi.tukang_id WHERE pesanan.tukang_id = $tukang_id";
$query = "SELECT * FROM tukang JOIN divisi ON tukang.id = divisi.tukang_id WHERE tukang.id = $tukang_id";
} else {
// $query = "SELECT * FROM pesanan JOIN divisi ON pesanan.tukang_id = divisi.tukang_id";
$query = "SELECT * FROM tukang JOIN divisi ON tukang.id = divisi.tukang_id";
}
$get = pg_query($connect, $query);
$data = array();
if (pg_num_rows($get) > 0) {
while ($row = pg_fetch_assoc($get)) {
$data[] = $row;
}
set_response(true, "Data divisi ditemukan", $data);
} else {
set_response(false, "Data divisi tidak ditemukan", $data);
}
function set_response($isSuccess, $message, $data)
{
$result = array(
'isSuccess' => $isSuccess,
'message' => $message,
'data' => $data
);
echo json_encode($result);
}