commit b9ed6a8032b698e806866776ad8228d545d691ed
Author: Tomáš Pašek <pasek.thomas@gmail.com>
Date:   Thu Mar 25 18:55:40 2021 +0100

    Feature #8345 Implementce filterů dat - Server
    
    vytvořené objekty databáze, posílání json objektu klientu

diff --git a/application/controller/TableController.php b/application/controller/TableController.php
index d2cfa84..63d1ad8 100644
--- a/application/controller/TableController.php
+++ b/application/controller/TableController.php
@@ -1,12 +1,25 @@
 <?php
 require "../model/DB.php";
+require "../model/Tag.php";
+require "../model/Word.php";
 $DB = new DB();
 
 // (B) SEARCH FOR USERS
 $results = $DB->select(
-    "SELECT * FROM dd_wordform limit 10"
+    "SELECT w.id, w.context, w.date, w.description, w.description2, w.description3, w.ending, w.finished,
+w.namedentity, w.position1, w.position2, w.positiondetail, w.word, w.tag_id, w.lemma_id, t.tag, l.lemma, l.pos FROM dd_wordform as w left join dd_tag as t on w.tag_id = t.id left join dd_lemma as l on w.lemma_id = l.id order by w.id LIMIT 100"
 );
 
-// (C) OUTPUT RESULTS
-$result = json_encode(count($results)==0 ? null : $results);
+var_dump($results);
+
+$output = Array();
+foreach ($results as $res) {
+    $tag = new Tag($res["tag_id"], $res["tag"]);
+    $lemma = new Lemma($res["lemma_id"], $res["lemma"], $res["pos"]);
+    $word = new Word($res["id"],  $res["context"], $res["date"], $res["description"], $res["description2"], $res["description3"], $res["ending"],
+        $res["finished"], $res["namedentity"], $res["position1"], $res["position2"], $res["positiondetail"], $res["word"], $lemma, $tag);
+    array_push($output, $word);
+}
+
+$result = json_encode(count($output)==0 ? null : $output);
 echo $result;
\ No newline at end of file
diff --git a/application/model/Lemma.php b/application/model/Lemma.php
new file mode 100644
index 0000000..c38cbae
--- /dev/null
+++ b/application/model/Lemma.php
@@ -0,0 +1,14 @@
+<?php
+
+class Lemma {
+    public $id;
+    public $lemma;
+    public $pos;
+
+    public function __construct($id, $lemma, $pos)
+    {
+        $this->id = $id;
+        $this->lemma = $lemma;
+        $this->pos = $pos;
+    }
+}
\ No newline at end of file
diff --git a/application/model/Tag.php b/application/model/Tag.php
new file mode 100644
index 0000000..c184ec7
--- /dev/null
+++ b/application/model/Tag.php
@@ -0,0 +1,12 @@
+<?php
+
+class Tag {
+    public $id;
+    public $tag;
+
+    function __construct($id, $tag)
+    {
+        $this->id = $id;
+        $this->tag = $tag;
+    }
+}
\ No newline at end of file
diff --git a/application/model/Word.php b/application/model/Word.php
new file mode 100644
index 0000000..26854fc
--- /dev/null
+++ b/application/model/Word.php
@@ -0,0 +1,37 @@
+<?php
+class Word {
+    public $id;
+    public $context;
+    public $date;
+    public $description;
+    public $description2;
+    public $description3;
+    public $ending;
+    public $finished;
+    public $namedentity;
+    public $position1;
+    public $position2;
+    public $positiondetail;
+    public $word;
+    public $lemma;
+    public $tag;
+
+    function __construct($id, $context, $date, $description, $description2, $description3, $ending, $finished, $namedentity, $position1, $position2, $positiondetail, $word, $lemma, $tag)
+    {
+        $this->id = $id;
+        $this->context = $context;
+        $this->date = $date;
+        $this->description = $description;
+        $this->description2 = $description2;
+        $this->description3 = $description3;
+        $this->ending = $ending;
+        $this->finished = $finished;
+        $this->namedentity = $namedentity;
+        $this->position1 = $position1;
+        $this->position2 = $position2;
+        $this->positiondetail = $positiondetail;
+        $this->word = $word;
+        $this->lemma = $lemma;
+        $this->tag = $tag;
+    }
+}
\ No newline at end of file
diff --git a/application/view/Index.php b/application/view/Index.php
index 76473cc..e279ab4 100644
--- a/application/view/Index.php
+++ b/application/view/Index.php
@@ -6,7 +6,6 @@ include "../controller/TableController.php"
     function doSearch () {
         // (A1) GET SEARCH TERM
         var data = new FormData();
-
         // (A2) AJAX - USE HTTP:// NOT FILE://
         var xhr = new XMLHttpRequest();
         xhr.open("POST", "../controller/TableController.php");
