src/PageTypes/DatedUpdateHolder.php
public static function AllUpdates(
        $className = DatedUpdatePage::class,
        $parentID = null,
        $tagID = null,
        $dateFrom = null,
        $dateTo = null,
        $year = null,
        $monthNumber = null
    ) {

        $items = $className::get();
        $dbTableName = DataObject::getSchema()->tableForField($className, 'Date');
        if (!$dbTableName) {
            $dbTableName = DatedUpdatePage::class;
        }

        // Filter by parent holder.
        if (isset($parentID)) {
            $items = $items->filter(['ParentID'=>$parentID]);
        }

        // Filter down to a single tag.
        if (isset($tagID)) {
            $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);
            $tableName = DataObject::getSchema()->tableName($className);

            $items = $items->innerJoin(
                'BasePage_Terms',
                sprintf('"%s"."ID" = "BasePage_Terms"."BasePageID"', $tableName)
            )->innerJoin(
                $taxonomy,
                sprintf(
                    '"BasePage_Terms"."TaxonomyTermID" = "%s"."ID" AND "TaxonomyTerm"."ID" = \'%d\'',
                    $taxonomy,
                    $tagID
                )
            );
        }

        // Filter by date
        if (isset($dateFrom)) {
            if (!isset($dateTo)) {
                $dateTo = $dateFrom;
            }

            $items = $items->where([
                sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql("$dateFrom 00:00:00")),
                sprintf('"%s"."Date" <= \'%s\'', $dbTableName, Convert::raw2sql("$dateTo 23:59:59"))
            ]);
        }

        // Filter down to single month.
        if (isset($year) && isset($monthNumber)) {
            $year = (int)$year;
            $monthNumber = (int)$monthNumber;

            $beginDate = sprintf("%04d-%02d-01 00:00:00", $year, $monthNumber);
            $endDate = date('Y-m-d H:i:s', strtotime("{$beginDate} +1 month"));

            $items = $items->where(array(
                sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql($beginDate)),
                sprintf('"%s"."Date" < \'%s\'', $dbTableName, Convert::raw2sql($endDate))
            ));
        }

        // Unpaginated DataList.
        return $items;
    }
public static function AllUpdates(
        $className = DatedUpdatePage::class,
        $parentID = null,
        $tagID = null,
        $dateFrom = null,
        $dateTo = null,
        $year = null,
        $monthNumber = null
    ) {

        $items = $className::get();
        $dbTableName = DataObject::getSchema()->tableForField($className, 'Date');
        if (!$dbTableName) {
            $dbTableName = DatedUpdatePage::class;
        }

        // Filter by parent holder.
        if (isset($parentID)) {
            $items = $items->filter(['ParentID'=>$parentID]);
        }

        // Filter down to a single tag.
        if (isset($tagID)) {
            $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);
            $tableName = DataObject::getSchema()->tableName($className);

            $items = $items->innerJoin(
                'BasePage_Terms',
                sprintf('"%s"."ID" = "BasePage_Terms"."BasePageID"', $tableName)
            )->innerJoin(
                $taxonomy,
                sprintf(
                    '"BasePage_Terms"."TaxonomyTermID" = "%s"."ID" AND "TaxonomyTerm"."ID" = \'%d\'',
                    $taxonomy,
                    $tagID
                )
            );
        }

        // Filter by date
        if (isset($dateFrom)) {
            if (!isset($dateTo)) {
                $dateTo = $dateFrom;
            }

            $items = $items->where([
                sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql("$dateFrom 00:00:00")),
                sprintf('"%s"."Date" <= \'%s\'', $dbTableName, Convert::raw2sql("$dateTo 23:59:59"))
            ]);
        }

        // Filter down to single month.
        if (isset($year) && isset($monthNumber)) {
            $year = (int)$year;
            $monthNumber = (int)$monthNumber;

            $beginDate = sprintf("%04d-%02d-01 00:00:00", $year, $monthNumber);
            $endDate = date('Y-m-d H:i:s', strtotime("{$beginDate} +1 month"));

            $items = $items->where(array(
                sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql($beginDate)),
                sprintf('"%s"."Date" < \'%s\'', $dbTableName, Convert::raw2sql($endDate))
            ));
        }

        // Unpaginated DataList.
        return $items;
    }
public static function AllUpdates ( $ className = DatedUpdatePage :: class , $ parentID = null , $ tagID = null , $ dateFrom = null , $ dateTo = null , $ year = null , $ monthNumber = null ) { $ items = $ className :: get ( ) ; $ dbTableName = DataObject :: getSchema ( ) -> tableForField ( $ className , 'Date' ) ; if ( ! $ dbTableName ) { $ dbTableName = DatedUpdatePage :: class ; } // Filter by parent holder. if ( isset ( $ parentID ) ) { $ items = $ items -> filter ( [ 'ParentID' => $ parentID ] ) ; } // Filter down to a single tag. if ( isset ( $ tagID ) ) { $ taxonomy = DataObject :: getSchema ( ) -> tableName ( TaxonomyTerm :: class ) ; $ tableName = DataObject :: getSchema ( ) -> tableName ( $ className ) ; $ items = $ items -> innerJoin ( 'BasePage_Terms' , sprintf ( '"%s"."ID" = "BasePage_Terms"."BasePageID"' , $ tableName ) ) -> innerJoin ( $ taxonomy , sprintf ( '"BasePage_Terms"."TaxonomyTermID" = "%s"."ID" AND "TaxonomyTerm"."ID" = \'%d\'' , $ taxonomy , $ tagID ) ) ; } // Filter by date if ( isset ( $ dateFrom ) ) { if ( ! isset ( $ dateTo ) ) { $ dateTo = $ dateFrom ; } $ items = $ items -> where ( [ sprintf ( '"%s"."Date" >= \'%s\'' , $ dbTableName , Convert :: raw2sql ( "$dateFrom 00:00:00" ) ) , sprintf ( '"%s"."Date" <= \'%s\'' , $ dbTableName , Convert :: raw2sql ( "$dateTo 23:59:59" ) ) ] ) ; } // Filter down to single month. if ( isset ( $ year ) && isset ( $ monthNumber ) ) { $ year = ( int ) $ year ; $ monthNumber = ( int ) $ monthNumber ; $ beginDate = sprintf ( "%04d-%02d-01 00:00:00" , $ year , $ monthNumber ) ; $ endDate = date ( 'Y-m-d H:i:s' , strtotime ( "{$beginDate} +1 month" ) ) ; $ items = $ items -> where ( array ( sprintf ( '"%s"."Date" >= \'%s\'' , $ dbTableName , Convert :: raw2sql ( $ beginDate ) ) , sprintf ( '"%s"."Date" < \'%s\'' , $ dbTableName , Convert :: raw2sql ( $ endDate ) ) ) ) ; } // Unpaginated DataList. return $ items ; }
Find all site's updates, based on some filters.
Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.

@param string $className The name of the class to fetch.
@param int|null $parentID The ID of the holder to extract the updates from.
@param int|null $tagID The ID of the tag to filter the updates by.
@param string|null $dateFrom The beginning of a date filter range.
@param string|null $dateTo The end of the date filter range. If empty, only one day will be searched for.
@param int|null $year Numeric value of the year to show.
@param int|null $monthNumber Numeric value of the month to show.

@returns DataList | PaginatedList
Find all site s updates based on some filters . Omitting parameters will prevent relevant filters from being applied . The filters are ANDed together .