| @@ 241-259 (lines=19) @@ | ||
| 238 | * @param boolean $publish If it needs to be publish |
|
| 239 | * @return int With count of content in database |
|
| 240 | */ |
|
| 241 | public function countAllContent($publish = true){ |
|
| 242 | $now = date('Y-m-d H:i:s'); |
|
| 243 | $params = []; |
|
| 244 | ||
| 245 | $this->db->select("COUNT(id) AS countAll") |
|
| 246 | ->from("Content") |
|
| 247 | ->where("`deleted` IS NULL"); |
|
| 248 | ||
| 249 | if($publish){ |
|
| 250 | $this->db->andWhere("published <= ?"); |
|
| 251 | $params[] = $now; |
|
| 252 | } |
|
| 253 | ||
| 254 | $this->db->execute($params); |
|
| 255 | ||
| 256 | $this->db->setFetchModeClass(__CLASS__); |
|
| 257 | $count = $this->db->fetchOne(); |
|
| 258 | return $count->countAll; |
|
| 259 | } |
|
| 260 | ||
| 261 | /** |
|
| 262 | * Count all content of one type from database |
|
| @@ 268-287 (lines=20) @@ | ||
| 265 | * @param string $type Wich type of content ex. blog, page etc. |
|
| 266 | * @return int With count of content in database |
|
| 267 | */ |
|
| 268 | public function countAllContentOfType($type, $publish = true){ |
|
| 269 | $now = date('Y-m-d H:i:s'); |
|
| 270 | $params = [$type]; |
|
| 271 | ||
| 272 | $this->db->select("COUNT(id) AS countAll") |
|
| 273 | ->from("Content") |
|
| 274 | ->where("`type` = ?") |
|
| 275 | ->andWhere("`deleted` IS NULL"); |
|
| 276 | ||
| 277 | if($publish){ |
|
| 278 | $this->db->andWhere("published <= ?"); |
|
| 279 | $params[] = $now; |
|
| 280 | } |
|
| 281 | ||
| 282 | $this->db->execute($params); |
|
| 283 | ||
| 284 | $this->db->setFetchModeClass(__CLASS__); |
|
| 285 | $count = $this->db->fetchOne(); |
|
| 286 | return $count->countAll; |
|
| 287 | } |
|
| 288 | ||
| 289 | /** |
|
| 290 | * Count all content of one tag and one type from database |
|