src/Versioned.php
public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "")
    {
        // Make sure the table names are not postfixed (e.g. _Live)
        $oldMode = static::get_reading_mode();
        static::set_stage(static::DRAFT);

        $owner = $this->owner;
        $list = DataObject::get(DataObject::getSchema()->baseDataClass($owner), $filter, $sort, $join, $limit);
        if ($having) {
            // @todo - This method doesn't exist on DataList
            $list->having($having);
        }

        $query = $list->dataQuery()->query();

        $baseTable = null;
        foreach ($query->getFrom() as $table => $tableJoin) {
            if (is_string($tableJoin) && $tableJoin[0] == '"') {
                $baseTable = str_replace('"', '', $tableJoin);
            } elseif (is_string($tableJoin) && substr($tableJoin, 0, 5) != 'INNER') {
                $query->setFrom([
                    $table => "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\"=\"{$baseTable}_Versions\".\"RecordID\""
                        . " AND \"$table\".\"Version\" = \"{$baseTable}_Versions\".\"Version\""
                ]);
            }
            $query->renameTable($table, $table . '_Versions');
        }

        // Add all <basetable>_Versions columns
        foreach (Config::inst()->get(static::class, 'db_for_versions_table') as $name => $type) {
            $query->selectField(sprintf('"%s_Versions"."%s"', $baseTable, $name), $name);
        }

        $query->addWhere([
            "\"{$baseTable}_Versions\".\"RecordID\" = ?" => $owner->ID
        ]);
        $query->setOrderBy(($sort) ? $sort
            : "\"{$baseTable}_Versions\".\"LastEdited\" DESC, \"{$baseTable}_Versions\".\"Version\" DESC");

        $records = $query->execute();
        $versions = new ArrayList();

        foreach ($records as $record) {
            $versions->push(new Versioned_Version($record));
        }

        Versioned::set_reading_mode($oldMode);
        return $versions;
    }
public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "")
    {
        // Make sure the table names are not postfixed (e.g. _Live)
        $oldMode = static::get_reading_mode();
        static::set_stage(static::DRAFT);

        $owner = $this->owner;
        $list = DataObject::get(DataObject::getSchema()->baseDataClass($owner), $filter, $sort, $join, $limit);
        if ($having) {
            // @todo - This method doesn't exist on DataList
            $list->having($having);
        }

        $query = $list->dataQuery()->query();

        $baseTable = null;
        foreach ($query->getFrom() as $table => $tableJoin) {
            if (is_string($tableJoin) && $tableJoin[0] == '"') {
                $baseTable = str_replace('"', '', $tableJoin);
            } elseif (is_string($tableJoin) && substr($tableJoin, 0, 5) != 'INNER') {
                $query->setFrom([
                    $table => "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\"=\"{$baseTable}_Versions\".\"RecordID\""
                        . " AND \"$table\".\"Version\" = \"{$baseTable}_Versions\".\"Version\""
                ]);
            }
            $query->renameTable($table, $table . '_Versions');
        }

        // Add all <basetable>_Versions columns
        foreach (Config::inst()->get(static::class, 'db_for_versions_table') as $name => $type) {
            $query->selectField(sprintf('"%s_Versions"."%s"', $baseTable, $name), $name);
        }

        $query->addWhere([
            "\"{$baseTable}_Versions\".\"RecordID\" = ?" => $owner->ID
        ]);
        $query->setOrderBy(($sort) ? $sort
            : "\"{$baseTable}_Versions\".\"LastEdited\" DESC, \"{$baseTable}_Versions\".\"Version\" DESC");

        $records = $query->execute();
        $versions = new ArrayList();

        foreach ($records as $record) {
            $versions->push(new Versioned_Version($record));
        }

        Versioned::set_reading_mode($oldMode);
        return $versions;
    }
public function allVersions ( $ filter = "" , $ sort = "" , $ limit = "" , $ join = "" , $ having = "" ) { // Make sure the table names are not postfixed (e.g. _Live) $ oldMode = static :: get_reading_mode ( ) ; static :: set_stage ( static :: DRAFT ) ; $ owner = $ this -> owner ; $ list = DataObject :: get ( DataObject :: getSchema ( ) -> baseDataClass ( $ owner ) , $ filter , $ sort , $ join , $ limit ) ; if ( $ having ) { // @todo - This method doesn't exist on DataList $ list -> having ( $ having ) ; } $ query = $ list -> dataQuery ( ) -> query ( ) ; $ baseTable = null ; foreach ( $ query -> getFrom ( ) as $ table => $ tableJoin ) { if ( is_string ( $ tableJoin ) && $ tableJoin [ 0 ] == '"' ) { $ baseTable = str_replace ( '"' , '' , $ tableJoin ) ; } elseif ( is_string ( $ tableJoin ) && substr ( $ tableJoin , 0 , 5 ) != 'INNER' ) { $ query -> setFrom ( [ $ table => "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\"=\"{$baseTable}_Versions\".\"RecordID\"" . " AND \"$table\".\"Version\" = \"{$baseTable}_Versions\".\"Version\"" ] ) ; } $ query -> renameTable ( $ table , $ table . '_Versions' ) ; } // Add all <basetable>_Versions columns foreach ( Config :: inst ( ) -> get ( static :: class , 'db_for_versions_table' ) as $ name => $ type ) { $ query -> selectField ( sprintf ( '"%s_Versions"."%s"' , $ baseTable , $ name ) , $ name ) ; } $ query -> addWhere ( [ "\"{$baseTable}_Versions\".\"RecordID\" = ?" => $ owner -> ID ] ) ; $ query -> setOrderBy ( ( $ sort ) ? $ sort : "\"{$baseTable}_Versions\".\"LastEdited\" DESC, \"{$baseTable}_Versions\".\"Version\" DESC" ) ; $ records = $ query -> execute ( ) ; $ versions = new ArrayList ( ) ; foreach ( $ records as $ record ) { $ versions -> push ( new Versioned_Version ( $ record ) ) ; } Versioned :: set_reading_mode ( $ oldMode ) ; return $ versions ; }
Return a list of all the versions available.

@param  string $filter
@param  string $sort
@param  string $limit
@param  string $join @deprecated use leftJoin($table, $joinClause) instead
@param  string $having @deprecated
@return ArrayList
Return a list of all the versions available .