public static function getCascadeOptionArray(
        $db,
        $table,
        $title_field,
        $id_field,
        $cascade_field,
        $order_by_clause = null,
        $where_clause = null
    ) {
        $title_field = new SwatDBField($title_field, 'text');
        $id_field = new SwatDBField($id_field, 'integer');
        $cascade_field = new SwatDBField($cascade_field, 'integer');

        $sql = 'select %s, %s, %s from %s';
        $sql = sprintf(
            $sql,
            $id_field->name,
            $title_field->name,
            $cascade_field->name,
            $table
        );

        if ($where_clause !== null) {
            $sql .= ' where ' . $where_clause;
        }

        $sql .= ' order by ' . $cascade_field->name;
        if ($order_by_clause !== null) {
            $sql .= ', ' . $order_by_clause;
        }

        $rs = self::query($db, $sql, null);

        $options = array();
        $current = null;
        $title_field_name = $title_field->name;
        $id_field_name = $id_field->name;
        $cascade_field_name = $cascade_field->name;

        $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT);
        while ($row) {
            if (MDB2::isError($row)) {
                throw new SwatDBException($row);
            }

            if ($row->$cascade_field_name != $current) {
                $current = $row->$cascade_field_name;
                $options[$current] = array();
            }

            $options[$current][$row->$id_field_name] = $row->$title_field_name;
            $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT);
        }

        return $options;
    }