c3gov connector
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
DB_HOST=db
|
||||||
|
DB_NAME=
|
||||||
|
DB_USER=
|
||||||
|
DB_PASS=
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.env
|
||||||
|
.idea
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace lib;
|
||||||
|
|
||||||
|
class C3GovConnector
|
||||||
|
{
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
private $dbConnection;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
$this->config = parse_ini_file("../.env", true);
|
||||||
|
$this->dbConnection = new \mysqli($this->config['DB_HOST'], $this->config['DB_USER'], $this->config['DB_PASS'], $this->config['DB_NAME']);
|
||||||
|
$this->dbConnection->set_charset("utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPreApplication($referenceNumber){
|
||||||
|
$sql = "SELECT * FROM pre_applications WHERE reference_number = ?";
|
||||||
|
$stmt = $this->dbConnection->prepare($sql);
|
||||||
|
$stmt->bind_param("s", $referenceNumber);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
return $result->fetch_assoc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __destruct() {
|
||||||
|
$this->dbConnection->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include("../lib/C3GovConnector.php");
|
||||||
|
|
||||||
|
use lib\C3GovConnector;
|
||||||
|
|
||||||
|
$refNo = $_POST['referenceNumber'] ?? null;
|
||||||
|
//$refNo = $argv[1] ?? null;
|
||||||
|
|
||||||
|
if (!$refNo) {
|
||||||
|
echo( json_encode( [ 'error' => 'No reference number provided' ] ));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$c3gov = new C3GovConnector();
|
||||||
|
echo( json_encode($c3gov->getPreApplication($refNo)));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user