parent
817bb55d71
commit
cc195dcf90
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include_once __DIR__ . '/../models/job.php';
|
||||
|
||||
if ($_REQUEST['action'] === 'post'){
|
||||
$requestBody = file_get_contents('php://input');
|
||||
$body = json_decode($requestBody);
|
||||
|
||||
$newJob = new Job(null, $body->person_id, $body->company_id);
|
||||
|
||||
$allJobs = Jobs::create($newJob);
|
||||
|
||||
echo json_encode($allJobs);
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
INSERT INTO jobs (person_id, company_id) VALUES ($1, $2)
|
||||
@ -0,0 +1,23 @@
|
||||
<?
|
||||
include_once __DIR__ . '/../database/db.php';
|
||||
|
||||
class Job {
|
||||
public $id;
|
||||
public $person_id;
|
||||
public $company_id;
|
||||
public function __construct($id, $person_id, $company_id) {
|
||||
$this->id = $id;
|
||||
$this->person_id = $person_id;
|
||||
$this->company_id = $company_id;
|
||||
}
|
||||
}
|
||||
|
||||
class Jobs {
|
||||
static function create($job){
|
||||
$query = file_get_contents(__DIR__ . '/../database/sql/jobs/create.sql');
|
||||
$result = pg_query_params($query, array($job->person_id, $job->company_id));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in new issue