public function getList(array $options = array())
    {
        $sql = 'SELECT *';

        if (!empty($options['count'])) {
            $sql = 'SELECT COUNT(credential_id)';
        }

        $sql .= ' FROM module_gapi_credential WHERE credential_id IS NOT NULL';

        $conditions = array();

        if (isset($options['type'])) {
            $sql .= ' AND type=?';
            $conditions[] = $options['type'];
        }

        $allowed_order = array('asc', 'desc');
        $allowed_sort = array('name', 'credential_id', 'created', 'modified', 'type');

        if (isset($options['sort'])
            && in_array($options['sort'], $allowed_sort)
            && isset($options['order'])
            && in_array($options['order'], $allowed_order)) {
            $sql .= " ORDER BY {$options['sort']} {$options['order']}";
        } else {
            $sql .= ' ORDER BY created DESC';
        }

        if (!empty($options['limit'])) {
            $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
        }

        if (empty($options['count'])) {
            $fetch_options = array('index' => 'credential_id', 'unserialize' => 'data');
            $result = $this->db->fetchAll($sql, $conditions, $fetch_options);
        } else {
            $result = (int) $this->db->fetchColumn($sql, $conditions);
        }

        return $result;
    }