Summary Files Commits Branches @commit @diff @stats
path: root / src / models
diff options
context:
space:
mode:
2 files changed, 19 insertions, 6 deletions
-rw-r--r--src/models/DBModel.php12
-rw-r--r--src/models/JobOffer.php13
diff --git a/src/models/DBModel.php b/src/models/DBModel.php
new file mode 100644
index 0000000..65bb725
--- /dev/null
+++ b/src/models/DBModel.php
@@ -0,0 +1,12 @@
+<?php
+include_once("DB.php");
+
+abstract class DBModel {
+ protected static $DB;
+
+ public static function __constructStatic() {
+ self::$DB = new DB();
+ }
+}
+
+DBModel::__constructStatic();
diff --git a/src/models/JobOffer.php b/src/models/JobOffer.php
index 1fb3d28..d4268db 100644
--- a/src/models/JobOffer.php
+++ b/src/models/JobOffer.php
@@ -1,7 +1,7 @@
<?php
-include_once("DB.php");
+include_once("DBModel.php");
-class JobOffer {
+class JobOffer extends DBModel {
public const TABLE_NAME = "job_offers";
public const TABLE_COLUMNS = array("title " . DB::STRING_TYPE, "description " . DB::STRING_TYPE, "company " . DB::STRING_TYPE, "salary " . DB::FLOAT_TYPE);
@@ -10,9 +10,10 @@ class JobOffer {
public string $company;
public float $salary;
- private DB $db;
-
- function __construct(DB $db) {
- $this->db = $db;
+ function __construct(string $title, string $description, string $company, float $salary) {
+ $this->title = $title;
+ $this->description = $description;
+ $this->company = $company;
+ $this->salary = $salary;
}
}