Projekt

Obecné

Profil

Stáhnout (21.2 KB) Statistiky
| Větev: | Revize:
1 3b343aea Tomáš Pašek
<?php
2
class DB {
3
    // (A) CONNECT TO DATABASE
4
    public $error = "";
5
    private $pdo = null;
6
    private $stmt = null;
7
    function __construct () {
8
        try {
9
            $this->pdo = new PDO(
10
                "pgsql:host=".DB_HOST.";dbname=".DB_NAME,
11
                DB_USER, DB_PASSWORD, [
12
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
13
                    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
14
                ]
15
            );
16
        } catch (Exception $ex) { die($ex->getMessage()); }
17
    }
18
19
    // (B) CLOSE CONNECTION
20
    function __destruct(){
21
        if ($this->stmt!==null) { $this->stmt = null; }
22
        if ($this->pdo!==null) { $this->pdo = null; }
23
    }
24
25
    // (C) RUN A SELECT QUERY
26
    function select($sql, $cond=null){
27
        $result = false;
28
        try {
29
            $this->stmt = $this->pdo->prepare($sql);
30 2a99773b Milan Vacek
            if (array_key_exists("lemma", $params)) {
31
                $this->stmt->bindParam(':lemma',$params['lemma'], PDO::PARAM_STR);
32
            }
33
            if (array_key_exists("word", $params)) {
34
                $this->stmt->bindParam(':word',$params['word'], PDO::PARAM_STR);
35
            }
36
            if (array_key_exists("position1", $params)) {
37
                $this->stmt->bindParam(':position1',$params['position1'], PDO::PARAM_INT);
38
            }
39
            if (array_key_exists("position2", $params)) {
40
                $this->stmt->bindParam(':position2',$params['position2'], PDO::PARAM_INT);
41
            }
42
            if (array_key_exists("positiondetail", $params)) {
43
                $this->stmt->bindParam(':positiondetail',$params['positiondetail'], PDO::PARAM_INT);
44
            }
45
            if (array_key_exists("tag", $params)) {
46
                $this->stmt->bindParam(':tag',$params['tag'], PDO::PARAM_STR);
47
            }
48
            if (array_key_exists("tag", $params)) {
49
                $this->stmt->bindParam(':tag',$params['tag'], PDO::PARAM_STR);
50
            }
51
            if (array_key_exists("finished", $params)) {
52
                $this->stmt->bindParam(':finished',$params['finished']);
53
            }
54
            if (array_key_exists("manuscript", $params)) {
55
                for ($x = 0; $x < count($params["manuscript"]); $x += 1) {
56
                    $this->stmt->bindParam(':manuscript'.$x,$params["manuscript"][$x], PDO::PARAM_INT);
57
                }
58
            }
59
            $this->stmt->execute();
60 3b343aea Tomáš Pašek
            $result = $this->stmt->fetchAll();
61
            return $result;
62
        } catch (Exception $ex) {
63
            $this->error = $ex->getMessage();
64
            return false;
65
        }
66
    }
67 2a99773b Milan Vacek
68
function update(){
69
70
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71
72
    $query = "UPDATE dd_wordform
73
                SET ";
74
75
76
    if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
77
        $query .= " context = :context, ";
78
    }
79
        $query .= " date = CURRENT_DATE,";
80
81
    if (array_key_exists("description", $_POST) && $_POST['description'] != "") {
82
        $query .= " description = :description, ";
83
    }
84
    if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") {
85
        $query .= " description2 = :description2, ";
86
    }
87
    if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") {
88
        $query .= " description3 = :description3, ";
89
    }
90
    if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") {
91
        $query .= " ending = :ending, ";
92
    }
93
    if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") {
94
        $query .= " finished = :finished, ";
95
    }
96
    if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") {
97
        $query .= " namedentity = :namedentity, ";
98
    }
99
    if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") {
100
        $query .= " position1 = :position1, ";
101
    }
102
    if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") {
103
        $query .= " position2 = :position2, ";
104
    }
105
    if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") {
106
        $query .= " positiondetail = :positiondetail ,";
107
    }
108
    if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") {
109
        $query .= " prefix = :prefix, ";
110
    }
111
    if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") {
112
        $query .= " suffix = :suffix, ";
113
    }
114
    if (array_key_exists("word", $_POST) && $_POST['word'] != "") {
115
        $query .= " word = :word, ";
116
    }
117
    if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
118
        $query .= " lemma_id = :lemma_id, ";
119
    }
120
    if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
121
        $query .= " tag_id = :tag_id ";
122
    }
123
124
    $query .= " WHERE ";
125
    if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
126
        $query .= " id = :id ;";
127
    }
128
129
    $this->stmt = $this->pdo->prepare($query);
130
131
    if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
132
        $this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR);
133
    }
134
    if (array_key_exists("description", $_POST) && $_POST['description'] != "") {
135
        $this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR);
136
    }
137
    if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") {
138
        $this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR);
139
    }
140
    if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") {
141
        $this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR);
142
    }
143
    if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") {
144
        $this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR);
145
    }
146
    if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") {
147
        $this->stmt->bindParam(':finished', $_POST['finished']);
148
    }
149
    if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") {
150
        $this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT);
151
    }
152
    if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") {
153
        $this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR);
154
    }
155
    if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") {
156
        $this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR);
157
    }
158
    if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") {
159
        $this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR);
160
    }
161
    if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") {
162
        $this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR);
163
    }
164
    if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") {
165
        $this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR);
166
    }
167
    if (array_key_exists("word", $_POST) && $_POST['word'] != "") {
168
        $this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR);
169
    }
170
    if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
171
        $this->stmt->bindParam(':lemma_id', $_POST['lemma_id'], PDO::PARAM_INT);
172
    }
173
    if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
174
        $this->stmt->bindParam(':tag_id', $_POST['tag_id'], PDO::PARAM_INT);
175
    }
176
    if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
177
        $this->stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
178
    }
179
180
    $this->stmt->execute();
181
182
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
183
184
    $query = "UPDATE dd_lemma
185
                 SET ";
186
187
    if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
188
        $query .= " lemma = :lemma , ";
189
    }
190
    if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
191
        $query .= " pos = :pos  ";
192
    }
193
194
    $query .= "WHERE ";
195
    if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
196
        $query .= " id = :lemma_id ;";
197
    }
198
199
200
    $this->stmt = $this->pdo->prepare($query);
201
    if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
202
        $this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR);
203
    }
204
    if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
205
        $this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT);
206
    }
207
    if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
208
        $this->stmt->bindParam(':lemma_id', $_POST['lemma_id'], PDO::PARAM_INT);
209
    }
210
    $this->stmt->execute();
211
212
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
213
214
    if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
215
        $query = "SELECT * FROM dd_manuscript WHERE ";
216
        $query .= " wordform_id = :wordform_id ;";
217
    }
218
219
    $this->stmt = $this->pdo->prepare($query);
220
    if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
221
        $this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
222
    }
223
    $this->stmt->execute();
224
    $result = $this->stmt->fetchAll();
225
226
    $to_insert = [];
227
    $to_delete = [];
228
    $contained = [];
229
    $found = false;
230
231
    foreach ($result as $res) {
232
        $integerIDs = array_map('intval', explode(',', $_POST['manuscript']));
233
        foreach ($integerIDs as $new_value){
234
            if($new_value == $res['manuscript']){
235
                $found = true;
236
                array_push($contained, $new_value);
237
            }
238
        }
239
        if($found == false){
240
            array_push($to_delete, $res);
241
        }
242
        $found = false;
243
    }
244
    $to_insert = array_diff($integerIDs, $contained);
245
246
    foreach ($to_delete as $id_to_delete){
247
        $query = "DELETE FROM dd_manuscript WHERE ";
248
        $query .= "manuscript = " . $id_to_delete['manuscript'] . " AND ";
249
        $query .= " wordform_id = :wordform_id ;";
250
251
252
        $this->stmt = $this->pdo->prepare($query);
253
        if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
254
            $this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
255
        }
256
        //
257
        $this->stmt->execute();
258
        var_dump($query);
259
    }
260
261
    foreach ($to_insert as $id_to_insert){
262
        $query = "INSERT INTO dd_manuscript VALUES ( ";
263
        $query .= " :wordform_id , ";
264
        $query .= " " . $id_to_insert . " ); ";
265
266
        $this->stmt = $this->pdo->prepare($query);
267
        if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
268
            $this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
269
        }
270
        $this->stmt->execute();
271
    }
272
273
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
274
275
    $query = "UPDATE dd_tag
276
                 SET ";
277
278
    if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
279
        $query .= " tag = :tag  ";
280
    }
281
282
    $query .= "WHERE ";
283
    if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
284
        $query .= " id = :tag_id ;";
285
    }
286
287
288
    $this->stmt = $this->pdo->prepare($query);
289
    if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
290
        $this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR);
291
    }
292
    if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
293
        $this->stmt->bindParam(':tag_id', $_POST['tag_id'], PDO::PARAM_INT);
294
    }
295
    $this->stmt->execute();
296 b315cd75 Milan Vacek
}
297
298
function insert(){
299
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
300
301
    $query = "SELECT MAX(id) FROM dd_wordform;";
302
    $this->stmt = $this->pdo->prepare($query);
303
    $this->stmt->execute();
304
    $result = $this->stmt->fetchAll();
305
    $result[0]["max"]+=1;
306
307
308
    $query = "INSERT INTO dd_wordform ( id, ";
309
    $values = "VALUES (" . $result[0]["max"] . ", ";
310
311
     if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
312
            $query .= " context, ";
313
            $values .= " :context, ";
314
        }
315
            $query .= " date, ";
316
            $values .=  " CURRENT_DATE, ";
317
318
        if (array_key_exists("description", $_POST) && $_POST['description'] != "") {
319
            $query .= " description, ";
320
            $values .= " :description, ";
321
        }
322
        if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") {
323
            $query .= " description2, ";
324
            $values .= " :description2, ";
325
        }
326
        if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") {
327
            $query .= " description3, ";
328
            $values .= " :description3, ";
329
        }
330
        if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") {
331
            $query .= " ending, ";
332
            $values .= " :ending, ";
333
        }
334
        if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") {
335
            $query .= " finished, ";
336
            $values .= " :finished, ";
337
        }
338
        if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") {
339
            $query .= " namedentity, ";
340
            $values .= " :namedentity, ";
341
        }
342
        if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") {
343
            $query .= " position1, ";
344
            $values .= " :position1, ";
345
        }
346
        if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") {
347
            $query .= " position2, ";
348
            $values .= " :position2, ";
349
        }
350
        if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") {
351
            $query .= " positiondetail, ";
352
            $values .= " :positiondetail, ";
353
        }
354
        if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") {
355
            $query .= " prefix, ";
356
            $values .= " :prefix, ";
357
        }
358
        if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") {
359
            $query .= " suffix, ";
360
            $values .= " :suffix, ";
361
        }
362
        if (array_key_exists("word", $_POST) && $_POST['word'] != "") {
363
            $query .= " word, ";
364
            $values .= " :word, ";
365
        }
366
        if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
367
            $query .= " lemma_id, ";
368
            $values .= " :lemma_id, ";
369
        }
370
        if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
371
            $query .= " tag_id ) ";
372
            $values .= " :tag_id ); ";
373
        }
374
375
        $query .= $values;
376
        $this->stmt = $this->pdo->prepare($query);
377
378
            if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
379
                $this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR);
380
            }
381
            if (array_key_exists("description", $_POST) && $_POST['description'] != "") {
382
                $this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR);
383
            }
384
            if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") {
385
                $this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR);
386
            }
387
            if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") {
388
                $this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR);
389
            }
390
            if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") {
391
                $this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR);
392
            }
393
            if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") {
394
                $this->stmt->bindParam(':finished', $_POST['finished']);
395
            }
396
            if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") {
397
                $this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT);
398
            }
399
            if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") {
400
                $this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR);
401
            }
402
            if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") {
403
                $this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR);
404
            }
405
            if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") {
406
                $this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR);
407
            }
408
            if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") {
409
                $this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR);
410
            }
411
            if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") {
412
                $this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR);
413
            }
414
            if (array_key_exists("word", $_POST) && $_POST['word'] != "") {
415
                $this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR);
416
            }
417
            if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
418
                $this->stmt->bindParam(':lemma_id', $_POST['lemma_id'], PDO::PARAM_INT);
419
            }
420
            if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
421
                $this->stmt->bindParam(':tag_id', $_POST['tag_id'], PDO::PARAM_INT);
422
            }
423
424
            $this->stmt->execute();
425
426
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
427
428
    $query = "SELECT MAX(id) FROM dd_lemma;";
429
    $this->stmt = $this->pdo->prepare($query);
430
    $this->stmt->execute();
431
    $result = $this->stmt->fetchAll();
432
    $result[0]["max"]+=1;
433
434
    $query = "INSERT INTO dd_lemma ( id, ";
435
    $values = "VALUES (" . $result[0]["max"] . ", ";
436
        if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
437
            $query .= " lemma, ";
438
            $values .= " :lemma, ";
439
        }
440
        if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
441
            $query .= " pos ) ";
442
            $values .= " :pos ); ";
443
        }
444
445
    $query .= $values;
446
    $this->stmt = $this->pdo->prepare($query);
447
        if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
448
            $this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR);
449
        }
450
        if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
451
            $this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT);
452
        }
453
    $this->stmt->execute();
454
455
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
456
457
    if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
458
        $query = "SELECT * FROM dd_manuscript WHERE ";
459
        $query .= " wordform_id = :wordform_id ;";
460
    }
461
462
    $this->stmt = $this->pdo->prepare($query);
463
    if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
464
        $this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
465
    }
466
    $this->stmt->execute();
467
    $result = $this->stmt->fetchAll();
468
469
    $to_insert = [];
470
    $contained = [];
471
    $found = false;
472
473
    foreach ($result as $res) {
474
        $integerIDs = array_map('intval', explode(',', $_POST['manuscript']));
475
        foreach ($integerIDs as $new_value){
476
            if($new_value == $res['manuscript']){
477
                $found = true;
478
                array_push($contained, $new_value);
479
            }
480
        }
481
        if($found == false){
482
            array_push($to_delete, $res);
483
        }
484
        $found = false;
485
    }
486
    $to_insert = array_diff($integerIDs, $contained);
487
    foreach ($to_insert as $id_to_insert){
488
        $query = "INSERT INTO dd_manuscript VALUES ( ";
489
        $query .= " :wordform_id , ";
490
        $query .= " " . $id_to_insert . " ); ";
491
492
        $this->stmt = $this->pdo->prepare($query);
493
        if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
494
            $this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
495
        }
496
        $this->stmt->execute();
497
    }
498
499
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
500
    $query = "SELECT MAX(id) FROM dd_tag;";
501
    $this->stmt = $this->pdo->prepare($query);
502
    $this->stmt->execute();
503
    $result = $this->stmt->fetchAll();
504
    $result[0]["max"]+=1;
505
506
507
    $query = "INSERT INTO dd_tag (id, ";
508
    $values = "VALUES (" . $result[0]["max"] . ", ";
509
510
        if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
511
            $query .= " tag ) ";
512
            $values .= " :tag ); ";
513
        }
514
515
    $query .= $values;
516
    $this->stmt = $this->pdo->prepare($query);
517
        if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
518
            $this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR);
519
        }
520
    $this->stmt->execute();
521
522
523
}
524
525
}
526 3b343aea Tomáš Pašek
527
// (D) DATABASE SETTINGS - CHANGE TO YOUR OWN!
528
define('DB_HOST', 'localhost');
529 2a99773b Milan Vacek
define('DB_NAME', 'dalim2');
530 3b343aea Tomáš Pašek
define('DB_CHARSET', 'utf8');
531
define('DB_USER', 'postgres');
532 b315cd75 Milan Vacek
define('DB_PASSWORD', 'MVcesko98');