Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
3 files changed, 21 insertions, 8 deletions
-rw-r--r--src/index.php4
-rw-r--r--src/models/DBModel.php12
-rw-r--r--src/models/JobOffer.php13
diff --git a/src/index.php b/src/index.php
index 86562ab..285f6e7 100644
--- a/src/index.php
+++ b/src/index.php
@@ -1,6 +1,6 @@
<p>Hello World!</p>
<?php
- include_once("models/DB.php");
+ include_once("models/JobOffer.php");
- $db = new DB();
+ $jb = new JobOffer("a", "", "", 0);
?>
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;
}
}