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 | public function fetchList() |
| 20 | { |
| 21 | try { |
| 22 | $sqlArgs = [$this->locale]; |
| 23 | $sql = 'SELECT data_json FROM topic WHERE locale = ?'; |
| 24 | |
| 25 | $topiclist = new Collection(); |
| 26 | |
| 27 | $stm = $this->access()->prepare($sql); |
| 28 | $stm->execute($sqlArgs); |
| 29 | $stm->fetchAll(\PDO::FETCH_FUNC, function ($data_json) use ($topiclist) { |
| 30 | $topic = new \BO\Zmsdldb\MySQL\Entity\Topic(); |
| 31 | $topic->offsetSet('data_json', $data_json); |
| 32 | |
| 33 | $topiclist[$topic['id']] = $topic; |
| 34 | }); |
| 35 | |
| 36 | return $topiclist; |
| 37 | } catch (\Exception $e) { |
| 38 | throw $e; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * |
| 44 | * @return Entity |
| 45 | */ |
| 46 | public function fetchPath($topic_path) |
| 47 | { |
| 48 | try { |
| 49 | $sqlArgs = [$this->locale, (string)$topic_path]; |
| 50 | $sql = 'SELECT data_json FROM topic WHERE locale = ? AND path = ?'; |
| 51 | |
| 52 | $stm = $this->access()->prepare($sql); |
| 53 | $stm->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, '\\BO\\Zmsdldb\\MySQL\\Entity\\Topic'); |
| 54 | $stm->execute($sqlArgs); |
| 55 | |
| 56 | if (!$stm || ($stm && $stm->rowCount() == 0)) { |
| 57 | return false; |
| 58 | } |
| 59 | $topic = $stm->fetch(); |
| 60 | return $topic; |
| 61 | } catch (\Exception $e) { |
| 62 | throw $e; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * |
| 68 | * @return Entity |
| 69 | */ |
| 70 | public function fetchId($topicId) |
| 71 | { |
| 72 | try { |
| 73 | $sqlArgs = [$this->locale, (int)$topicId]; |
| 74 | $sql = 'SELECT data_json FROM topic WHERE locale = ? AND id = ?'; |
| 75 | |
| 76 | $stm = $this->access()->prepare($sql); |
| 77 | $stm->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, '\\BO\\Zmsdldb\\MySQL\\Entity\\Topic'); |
| 78 | $stm->execute($sqlArgs); |
| 79 | |
| 80 | if (!$stm || ($stm && $stm->rowCount() == 0)) { |
| 81 | return false; |
| 82 | } |
| 83 | $topic = $stm->fetch(); |
| 84 | return $topic; |
| 85 | } catch (\Exception $e) { |
| 86 | throw $e; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | public function readSearchResultList($query) |
| 91 | { |
| 92 | try { |
| 93 | #$query = '+' . implode(' +', explode(' ', $query)); |
| 94 | $sqlArgs = [$this->locale, $this->locale, $query]; |
| 95 | $sql = "SELECT t.data_json |
| 96 | FROM search AS se |
| 97 | LEFT JOIN topic AS t ON t.id = se.object_id AND t.locale = ? |
| 98 | WHERE |
| 99 | se.locale = ? AND MATCH (search_value) AGAINST (? IN BOOLEAN MODE) |
| 100 | AND (search_type IN ('name', 'keywords', 'titles')) AND entity_type='topic' |
| 101 | GROUP BY se.object_id |
| 102 | "; |
| 103 | /* |
| 104 | if (!empty($service_csv)) { |
| 105 | $ids = explode(',', $service_csv); |
| 106 | $qm = array_fill(0, count($ids), '?'); |
| 107 | $sql .= ' AND se.object_id IN (' . implode(', ', $qm) . ')'; |
| 108 | array_push($sqlArgs, ...$ids); |
| 109 | }*/ |
| 110 | #print_r($sql);exit; |
| 111 | |
| 112 | $topiclist = new Collection(); |
| 113 | |
| 114 | $stm = $this->access()->prepare($sql); |
| 115 | $stm->execute($sqlArgs); |
| 116 | $stm->fetchAll(\PDO::FETCH_FUNC, function ($data_json) use ($topiclist) { |
| 117 | $topic = new \BO\Zmsdldb\MySQL\Entity\Topic(); |
| 118 | $topic->offsetSet('data_json', $data_json); |
| 119 | |
| 120 | $topiclist[$topic['id']] = $topic; |
| 121 | }); |
| 122 | |
| 123 | return $topiclist; |
| 124 | } catch (\Exception $e) { |
| 125 | throw $e; |
| 126 | } |
| 127 | } |
| 128 | } |