aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/User/Entity.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-22 01:18:02 +0200
committerThomas Lange <code@nerdmind.de>2021-06-22 01:46:42 +0200
commit8cd1105b111b89106f24c5b50795afb5ff28a935 (patch)
treec789faac9de4d83cb409c45779e76be8938a4d66 /core/namespace/User/Entity.php
parent7937df540b7d70b2bb87797442d0a0a0df197133 (diff)
downloadblog-8cd1105b111b89106f24c5b50795afb5ff28a935.tar.gz
blog-8cd1105b111b89106f24c5b50795afb5ff28a935.tar.xz
blog-8cd1105b111b89106f24c5b50795afb5ff28a935.zip
Implement new Repository and Entity classes
This commit adds new Repository and Entity classes which are better abstracted from the rest of the application. They dont know anymore about configuration options or how to parse to HTML because this is not the job for the ORM but for other parts of the application. The previous commits were a preparation for this big change. An entity now represents just a single record from a specific table of the database – nothing more. The repositories job is it to fetch or update records of the database and instantiate the entities. Another problem that was solved is the high amount of database queries that was needed before. For example, on the blogs home page first were all 10 latest post IDs fetched from the database and then another query was executed with "WHERE id = :id" for *each* single post?! ... This problem is solved with the new repository classes; they now use a single query to fetch and build the entities of the 10 latest posts. This change also solves the problem with database queries spread across the application and limits the exzessive use of try/catch blocks which were used before. The new classes make the whole code much cleaner. :)
Diffstat (limited to 'core/namespace/User/Entity.php')
-rw-r--r--core/namespace/User/Entity.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/namespace/User/Entity.php b/core/namespace/User/Entity.php
new file mode 100644
index 0000000..fdfaf9e
--- /dev/null
+++ b/core/namespace/User/Entity.php
@@ -0,0 +1,15 @@
+<?php
+namespace User;
+
+class Entity extends \Entity {
+ protected $id = FALSE;
+ protected $slug = FALSE;
+ protected $username = FALSE;
+ protected $password = FALSE;
+ protected $fullname = FALSE;
+ protected $mailaddr = FALSE;
+ protected $body = FALSE;
+ protected $argv = FALSE;
+ protected $time_insert = FALSE;
+ protected $time_update = FALSE;
+}