MINI
C:
/
xampp
/
htdocs
/
ktpel
/
app
/
Upload File:
files >> C:/xampp/htdocs/ktpel/app/person.php
<?php require_once __DIR__ . '/../config/database.php'; function find_person(string $nik): array { $app = require __DIR__ . '/../config/app.php'; [$conn, $err] = oracle_connect(); if (!$conn) return ['ok'=>false, 'error'=>$err]; if (!preg_match('/^\d{16}$/', $nik)) { return ['ok'=>false, 'error'=>'NIK harus 16 digit.']; } $c = $app['columns']; $select = []; foreach ($c as $key => $col) { $select[] = $col . ' AS ' . strtoupper($key); } $sql = "SELECT " . implode(", ", $select) . " FROM " . $app['schema'] . "." . $app['table_biodata'] . " WHERE " . $c['nik'] . " = :nik"; $st = oci_parse($conn, $sql); oci_bind_by_name($st, ':nik', $nik); if (!oci_execute($st)) { $e = oci_error($st); return ['ok'=>false, 'error'=>$e['message'] ?? 'Query gagal']; } $row = oci_fetch_assoc($st); if (!$row) return ['ok'=>false, 'error'=>'Data NIK tidak ditemukan.']; foreach ($row as $k => $v) { if ($v instanceof DateTime) $row[$k] = $v->format('d-m-Y'); } return ['ok'=>true, 'data'=>$row]; }
Copyright ©2021 || Defacer Indonesia