getShared('db'); $sql = <<query($sql); $query->setFetchMode(\Phalcon\Db::FETCH_ASSOC); return $query->fetchAll(); } public function countByTopicId(string $topicId): int { $connection = \Phalcon\DI::getDefault()->getShared('db'); $query = $connection->query("SELECT count(id) FROM forum_comments WHERE topic_id = '$topicId'"); return (int) $query->fetch()[0]; } }