| @@ 279-292 (lines=14) @@ | ||
| 276 | * @param \CriteriaElement $criteria {@link CriteriaElement} to match |
|
| 277 | * @return int count of answers |
|
| 278 | */ |
|
| 279 | public function getCount(\CriteriaElement $criteria = null) |
|
| 280 | { |
|
| 281 | $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('smartfaq_answers'); |
|
| 282 | if (isset($criteria) && is_subclass_of($criteria, 'CriteriaElement')) { |
|
| 283 | $sql .= ' ' . $criteria->renderWhere(); |
|
| 284 | } |
|
| 285 | $result = $this->db->query($sql); |
|
| 286 | if (!$result) { |
|
| 287 | return 0; |
|
| 288 | } |
|
| 289 | list($count) = $this->db->fetchRow($result); |
|
| 290 | ||
| 291 | return $count; |
|
| 292 | } |
|
| 293 | ||
| 294 | /** |
|
| 295 | * count answers matching a condition and group by faq ID |
|
| @@ 329-342 (lines=14) @@ | ||
| 326 | * @param object $criteria {@link CriteriaElement} to match |
|
| 327 | * @return int count of categories |
|
| 328 | */ |
|
| 329 | public function getCount($criteria = null) |
|
| 330 | { |
|
| 331 | $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('smartfaq_categories'); |
|
| 332 | if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) { |
|
| 333 | $sql .= ' ' . $criteria->renderWhere(); |
|
| 334 | } |
|
| 335 | $result = $this->db->query($sql); |
|
| 336 | if (!$result) { |
|
| 337 | return 0; |
|
| 338 | } |
|
| 339 | list($count) = $this->db->fetchRow($result); |
|
| 340 | ||
| 341 | return $count; |
|
| 342 | } |
|
| 343 | ||
| 344 | /** |
|
| 345 | * @param int $parentid |
|