|
|
|
@ -1,47 +1,45 @@
|
|
|
|
<?
|
|
|
|
<?
|
|
|
|
include_once __DIR__ . '/../database/db.php';
|
|
|
|
include_once __DIR__ . '/../database/db.php';
|
|
|
|
|
|
|
|
|
|
|
|
class Job {
|
|
|
|
class Location {
|
|
|
|
public $id;
|
|
|
|
public $id;
|
|
|
|
public $job_type;
|
|
|
|
public $street;
|
|
|
|
public function __construct($id, $person_id, $job_type, $company_id) {
|
|
|
|
public $city;
|
|
|
|
|
|
|
|
public $state;
|
|
|
|
|
|
|
|
public function __construct($id, $street, $city, $state) {
|
|
|
|
$this->id = $id;
|
|
|
|
$this->id = $id;
|
|
|
|
if($person_id){
|
|
|
|
$this->street = $street;
|
|
|
|
$this->person_id = $person_id;
|
|
|
|
$this->city = $city;
|
|
|
|
}
|
|
|
|
$this->state = $state;
|
|
|
|
$this->job_type = $job_type;
|
|
|
|
|
|
|
|
if($company_id){
|
|
|
|
|
|
|
|
$this->company_id = $company_id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Jobs {
|
|
|
|
class Locations {
|
|
|
|
static function find(){
|
|
|
|
static function find(){
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/jobs/find.sql');
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/locations/find.sql');
|
|
|
|
$result = pg_query($query);
|
|
|
|
$result = pg_query($query);
|
|
|
|
$jobs = array();
|
|
|
|
$locations = array();
|
|
|
|
while($data = pg_fetch_object($result)){
|
|
|
|
while($data = pg_fetch_object($result)){
|
|
|
|
$jobs[] = new Job(intval($data->id), intval($data->person_id), $data->job_type, intval($data->company_id));
|
|
|
|
$locations[] = new Location(intval($data->id), $data->street, $data->city, $data->state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $jobs;
|
|
|
|
return $locations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static function create($job){
|
|
|
|
static function create($location){
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/jobs/create.sql');
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/locations/create.sql');
|
|
|
|
$result = pg_query_params($query, array($job->person_id, $job->job_type, $job->company_id));
|
|
|
|
$result = pg_query_params($query, array($location->street, $location->city, $location->state));
|
|
|
|
|
|
|
|
|
|
|
|
return self::find();
|
|
|
|
return self::find();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static function delete($id){
|
|
|
|
static function delete($id){
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/jobs/delete.sql');
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/locations/delete.sql');
|
|
|
|
$result = pg_query_params($query, array($id));
|
|
|
|
$result = pg_query_params($query, array($id));
|
|
|
|
|
|
|
|
|
|
|
|
return self::find();
|
|
|
|
return self::find();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static function update($id, $updatedJob){
|
|
|
|
static function update($id, $updatedLocation){
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/jobs/update.sql');
|
|
|
|
$query = file_get_contents(__DIR__ . '/../database/sql/locations/update.sql');
|
|
|
|
$result = pg_query_params($query, array($updatedJob->person_id, $updatedJob->job_type, $updatedJob->company_id, $id));
|
|
|
|
$result = pg_query_params($query, array($updatedLocation->street, $updatedLocation->city, $updatedLocation->state, $id));
|
|
|
|
|
|
|
|
|
|
|
|
return self::find();
|
|
|
|
return self::find();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|