Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 49 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| Topic | |
0.00% |
0 / 49 |
|
0.00% |
0 / 4 |
210 | |
0.00% |
0 / 1 |
| fetchList | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| fetchPath | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
30 | |||
| fetchId | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
30 | |||
| readSearchResultList | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package ClientDldb |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsdldb\MySQL; |
| 9 | |
| 10 | use BO\Zmsdldb\MySQL\Entity\Topic as Entity; |
| 11 | use BO\Zmsdldb\MySQL\Collection\Topics as Collection; |
| 12 | use BO\Zmsdldb\Elastic\Topic as Base; |
| 13 | |
| 14 | /** |
| 15 | * |
| 16 | */ |
| 17 | class Topic extends Base |
| 18 | { |
| 19 | #[\Override] |
| 20 | public function fetchList() |
| 21 | { |
| 22 | try { |
| 23 | $sqlArgs = [$this->locale]; |
| 24 | $sql = 'SELECT data_json FROM topic WHERE locale = ?'; |
| 25 | |
| 26 | $topiclist = new Collection(); |
| 27 | |
| 28 | $stm = $this->access()->prepare($sql); |
| 29 | $stm->execute($sqlArgs); |
| 30 | $stm->fetchAll(\PDO::FETCH_FUNC, function ($data_json) use ($topiclist) { |
| 31 | $topic = new \BO\Zmsdldb\MySQL\Entity\Topic(); |
| 32 | $topic->offsetSet('data_json', $data_json); |
| 33 | |
| 34 | $topiclist[$topic['id']] = $topic; |
| 35 | }); |
| 36 | |
| 37 | return $topiclist; |
| 38 | } catch (\Exception $e) { |
| 39 | throw $e; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * |
| 45 | * @return Entity |
| 46 | */ |
| 47 | #[\Override] |
| 48 | public function fetchPath($topic_path) |
| 49 | { |
| 50 | try { |
| 51 | $sqlArgs = [$this->locale, (string)$topic_path]; |
| 52 | $sql = 'SELECT data_json FROM topic WHERE locale = ? AND path = ?'; |
| 53 | |
| 54 | $stm = $this->access()->prepare($sql); |
| 55 | $stm->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, '\\BO\\Zmsdldb\\MySQL\\Entity\\Topic'); |
| 56 | $stm->execute($sqlArgs); |
| 57 | |
| 58 | if (!$stm || ($stm && $stm->rowCount() == 0)) { |
| 59 | return false; |
| 60 | } |
| 61 | $topic = $stm->fetch(); |
| 62 | return $topic; |
| 63 | } catch (\Exception $e) { |
| 64 | throw $e; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * |
| 70 | * @return Entity |
| 71 | */ |
| 72 | #[\Override] |
| 73 | public function fetchId($itemId) |
| 74 | { |
| 75 | try { |
| 76 | $sqlArgs = [$this->locale, (int)$itemId]; |
| 77 | $sql = 'SELECT data_json FROM topic WHERE locale = ? AND id = ?'; |
| 78 | |
| 79 | $stm = $this->access()->prepare($sql); |
| 80 | $stm->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, '\\BO\\Zmsdldb\\MySQL\\Entity\\Topic'); |
| 81 | $stm->execute($sqlArgs); |
| 82 | |
| 83 | if (!$stm || ($stm && $stm->rowCount() == 0)) { |
| 84 | return false; |
| 85 | } |
| 86 | $topic = $stm->fetch(); |
| 87 | return $topic; |
| 88 | } catch (\Exception $e) { |
| 89 | throw $e; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #[\Override] |
| 94 | public function readSearchResultList($querystring) |
| 95 | { |
| 96 | try { |
| 97 | #$querystring = '+' . implode(' +', explode(' ', $querystring)); |
| 98 | $sqlArgs = [$this->locale, $this->locale, $querystring]; |
| 99 | $sql = "SELECT t.data_json |
| 100 | FROM search AS se |
| 101 | LEFT JOIN topic AS t ON t.id = se.object_id AND t.locale = ? |
| 102 | WHERE |
| 103 | se.locale = ? AND MATCH (search_value) AGAINST (? IN BOOLEAN MODE) |
| 104 | AND (search_type IN ('name', 'keywords', 'titles')) AND entity_type='topic' |
| 105 | GROUP BY se.object_id |
| 106 | "; |
| 107 | /* |
| 108 | if (!empty($service_csv)) { |
| 109 | $ids = explode(',', $service_csv); |
| 110 | $qm = array_fill(0, count($ids), '?'); |
| 111 | $sql .= ' AND se.object_id IN (' . implode(', ', $qm) . ')'; |
| 112 | array_push($sqlArgs, ...$ids); |
| 113 | }*/ |
| 114 | #print_r($sql);exit; |
| 115 | |
| 116 | $topiclist = new Collection(); |
| 117 | |
| 118 | $stm = $this->access()->prepare($sql); |
| 119 | $stm->execute($sqlArgs); |
| 120 | $stm->fetchAll(\PDO::FETCH_FUNC, function ($data_json) use ($topiclist) { |
| 121 | $topic = new \BO\Zmsdldb\MySQL\Entity\Topic(); |
| 122 | $topic->offsetSet('data_json', $data_json); |
| 123 | |
| 124 | $topiclist[$topic['id']] = $topic; |
| 125 | }); |
| 126 | |
| 127 | return $topiclist; |
| 128 | } catch (\Exception $e) { |
| 129 | throw $e; |
| 130 | } |
| 131 | } |
| 132 | } |