Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit3298938d8f3bc7d6dafd8e67311e4ff0afc8d288 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-03-31 22:01:00 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-03-31 22:01:00 +0300
Filesc37d36079540167f18f8162bba9526afb7d2ea6f /src
devrix-job-board-3298938d8f3bc7d6dafd8e67311e4ff0afc8d288.tar
devrix-job-board-3298938d8f3bc7d6dafd8e67311e4ff0afc8d288.tar.gz
devrix-job-board-3298938d8f3bc7d6dafd8e67311e4ff0afc8d288.zip
Parenteee825eb3ed35268c647a0e50904197eb2e953c5 (diff)
Implemented DBModel for storing an instance of DB
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;
}
}