<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collection_list(self, resource_id, resource_type="collection"):
 """ Fetches a list of all resource and component IDs within the specified resource. :param long resource_id: The ID of the resource to fetch children from. :param string resource_type: Specifies whether the resource to fetch is a collection or a child element. Defaults to 'collection'. :return: A list of longs representing the database resource IDs for all children of the requested record. :rtype list: """

        ret = []

        cursor = self.db.cursor()
        if resource_type == "collection":
            cursor.execute(
                "SELECT resourceComponentId FROM ResourcesComponents WHERE parentResourceComponentId IS NULL AND resourceId=%s",
                (resource_id),
            )
        else:
            ret.append(resource_id)
            cursor.execute(
                "SELECT resourceComponentId FROM ResourcesComponents WHERE parentResourceComponentId=%s",
                (resource_id),
            )

        rows = cursor.fetchall()
        if len(rows):
            for row in rows:
                ret.extend(self.collection_list(row[0], "description"))

        return ret