|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace KW\Inlagg; |
|
4
|
|
|
|
|
5
|
|
|
use Anax\Commons\ContainerInjectableInterface; |
|
6
|
|
|
use Anax\Commons\ContainerInjectableTrait; |
|
7
|
|
|
|
|
8
|
|
|
class Posta implements ContainerInjectableInterface |
|
9
|
|
|
{ |
|
10
|
|
|
use ContainerInjectableTrait; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
public function __construct($di) |
|
14
|
|
|
{ |
|
15
|
|
|
$this->di = $di; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Create a part of a table containing one type, one link, ordered by date or rank |
|
20
|
|
|
* |
|
21
|
|
|
* @param string $str the string to format as slug. |
|
22
|
|
|
* |
|
23
|
|
|
* @return str the formatted slug. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function postaNyKommentar($data, $userid, $tillhor, $type) |
|
26
|
|
|
{ |
|
27
|
|
|
$db = $this->di->get("db"); |
|
28
|
|
|
$db->connect(); |
|
29
|
|
|
$sql = "INSERT INTO inlagg (`data`, `userid`, `tillhor`, `type`, `rankning`) VALUES (?, ?, ?, ?, ?);"; |
|
30
|
|
|
$db->execute($sql, [$data, $userid, $tillhor, $type, 0]); |
|
31
|
|
|
|
|
32
|
|
|
return; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function postaSvar($data, $userid, $tillhor, $type) |
|
36
|
|
|
{ |
|
37
|
|
|
$db = $this->di->get("db"); |
|
38
|
|
|
$db->connect(); |
|
39
|
|
|
$sql = "INSERT INTO inlagg (`data`, `userid`, `tillhor`, `type`, `rankning`) VALUES (?, ?, ?, ?, ?);"; |
|
40
|
|
|
$db->execute($sql, [$data, $userid, $tillhor, $type, 0]); |
|
41
|
|
|
|
|
42
|
|
|
return; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function nyaTaggar($nyataggar) |
|
46
|
|
|
{ |
|
47
|
|
|
$db = $this->di->get("db"); |
|
48
|
|
|
$db->connect(); |
|
49
|
|
|
foreach ($nyataggar as $value) { |
|
50
|
|
|
$sql = "INSERT INTO taggar (`tagg`) VALUES (?);"; |
|
51
|
|
|
$db->execute($sql, [$value]); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function postaFraga($title, $data, $slug, $userid) |
|
56
|
|
|
{ |
|
57
|
|
|
$db = $this->di->get("db"); |
|
58
|
|
|
$db->connect(); |
|
59
|
|
|
$sql = "INSERT INTO inlagg (`title`, `data`, `type`, `slug`, `rankning`, `userid`) VALUES (?, ?, ?, ?, ?, ?);"; |
|
60
|
|
|
$db->execute($sql, [$title, $data, "fraga", $slug, 0, $userid]); |
|
61
|
|
|
|
|
62
|
|
|
return; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function kopplaFragaTaggar($id, $valdataggar) |
|
66
|
|
|
{ |
|
67
|
|
|
$db = $this->di->get("db"); |
|
68
|
|
|
$db->connect(); |
|
69
|
|
|
foreach ($valdataggar as $value) { |
|
70
|
|
|
$sql = "INSERT INTO inlaggtagg (`inlagg`, `tagg`) VALUES (?, ?);"; |
|
71
|
|
|
$db->execute($sql, [$id, $value]); |
|
72
|
|
|
} |
|
73
|
|
|
return; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|