getShared('db'); $query = $connection->query("SELECT count(id) FROM forum_topics WHERE slug = '$slug'"); return 0 !== (int) $query->fetch()[0]; } public function findByCategoryIdOrderedByLastActivity(string $categoryId, int $count, int $skip = 0): array { $connection = \Phalcon\DI::getDefault()->getShared('db'); $sql = <<query($sql); $query->setFetchMode(\Phalcon\Db::FETCH_ASSOC); return $query->fetchAll(); } public function countByCategoryId(string $categoryId): int { $connection = \Phalcon\DI::getDefault()->getShared('db'); $query = $connection->query("SELECT count(id) FROM forum_topics WHERE category_id = '$categoryId'"); return (int) $query->fetch()[0]; } public function getByCategoryIdAndSlug(string $categoryId, string $slug): array { $connection = \Phalcon\DI::getDefault()->getShared('db'); $sql = <<query($sql); $query->setFetchMode(\Phalcon\Db::FETCH_ASSOC); return $query->fetch(); } }