Summary Files Commits Branches @commit @diff @stats
path: root / src / models / Company.php
diff options
context:
space:
mode:
Commit1787135de8e42d1319f72f4f4b2798aaf8b34c10 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-04-01 12:23:17 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-04-01 12:23:17 +0300
Files0bb5d90d66b63a8a80938a268c501c5b2d66aae8 /src/models/Company.php
devrix-job-board-1787135de8e42d1319f72f4f4b2798aaf8b34c10.tar
devrix-job-board-1787135de8e42d1319f72f4f4b2798aaf8b34c10.tar.gz
devrix-job-board-1787135de8e42d1319f72f4f4b2798aaf8b34c10.zip
Parent73df4ef3ee7d01bbdd8af367de0439e190ff5350 (diff)
Added a Company model
1 files changed, 43 insertions, 0 deletions
-rw-r--r--src/models/Company.php43
diff --git a/src/models/Company.php b/src/models/Company.php
new file mode 100644
index 0000000..02d073c
--- /dev/null
+++ b/src/models/Company.php
@@ -0,0 +1,43 @@
+<?php
+include_once("DBModel.php");
+
+class Company extends DBModel {
+ public const TABLE_NAME = "companies";
+ public const TABLE_COLUMNS = array(
+ "name " . DB::STRING_TYPE,
+ );
+
+ public string $name;
+
+ function __construct(string $name) {
+ $this->name = $name;
+ }
+
+ static function __constructStatic() {
+ self::$DB->createTable(self::TABLE_NAME, self::TABLE_COLUMNS);
+ }
+
+ /* Create */
+
+ /**
+ * Inserts the giveb JobOffer into the databse. The id is automatically generated in the database.
+ *
+ * @param Company $com
+ */
+ static function insertIntoDB($com) {
+ self::$DB->insertValue(self::TABLE_NAME, $com->name);
+ }
+
+ /* Read */
+
+ /**
+ * Returns all Companies from the database.
+ *
+ * @return Company[]
+ */
+ static function getAllFromDB() {
+ return self::$DB->getAllValues(self::TABLE_NAME);
+ }
+}
+
+Company::__constructStatic();