| @@ 27-44 (lines=18) @@ | ||
| 24 | * |
|
| 25 | * @return array|false |
|
| 26 | */ |
|
| 27 | public function findPostByPath($category, $path) |
|
| 28 | { |
|
| 29 | $query = " |
|
| 30 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
|
| 31 | FROM `jpemeric_blog`.`post` |
|
| 32 | WHERE `path` = :path AND `category` = :category AND `display` = :is_active |
|
| 33 | LIMIT 1"; |
|
| 34 | $bindings = [ |
|
| 35 | 'path' => $path, |
|
| 36 | 'category' => $category, |
|
| 37 | 'is_active' => 1, |
|
| 38 | ]; |
|
| 39 | ||
| 40 | return $this |
|
| 41 | ->connections |
|
| 42 | ->getRead() |
|
| 43 | ->fetchOne($query, $bindings); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function getActivePosts($limit = null, $offset = 0) |
|
| 47 | { |
|
| @@ 108-125 (lines=18) @@ | ||
| 105 | ->fetchAll($query, $bindings); |
|
| 106 | } |
|
| 107 | ||
| 108 | public function getActivePostsCountByTag($tag) |
|
| 109 | { |
|
| 110 | $query = " |
|
| 111 | SELECT COUNT(1) AS `count` |
|
| 112 | FROM `jpemeric_blog`.`post` |
|
| 113 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
|
| 114 | `ptlink`.`tag_id` = :tag_id |
|
| 115 | WHERE `display` = :is_active"; |
|
| 116 | $bindings = [ |
|
| 117 | 'tag_id' => $tag, |
|
| 118 | 'is_active' => 1, |
|
| 119 | ]; |
|
| 120 | ||
| 121 | return $this |
|
| 122 | ->connections |
|
| 123 | ->getRead() |
|
| 124 | ->fetchValue($query, $bindings); |
|
| 125 | } |
|
| 126 | ||
| 127 | public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
| 128 | { |
|
| @@ 149-164 (lines=16) @@ | ||
| 146 | ->fetchAll($query, $bindings); |
|
| 147 | } |
|
| 148 | ||
| 149 | public function getActivePostsCountByCategory($category) |
|
| 150 | { |
|
| 151 | $query = " |
|
| 152 | SELECT COUNT(1) AS `count` |
|
| 153 | FROM `jpemeric_blog`.`post` |
|
| 154 | WHERE `category` = :category AND `display` = :is_active"; |
|
| 155 | $bindings = [ |
|
| 156 | 'category' => $category, |
|
| 157 | 'is_active' => 1, |
|
| 158 | ]; |
|
| 159 | ||
| 160 | return $this |
|
| 161 | ->connections |
|
| 162 | ->getRead() |
|
| 163 | ->fetchValue($query, $bindings); |
|
| 164 | } |
|
| 165 | ||
| 166 | public function getActivePostsByRelatedTags($post, $limit = 4) |
|
| 167 | { |
|