src/ORM/DataObject.php
public static function get_by_id($classOrID, $idOrCache = null, $cache = true)
    {
        // Shift arguments if passing id in first or second argument
        list ($class, $id, $cached) = is_numeric($classOrID)
            ? [get_called_class(), $classOrID, isset($idOrCache) ? $idOrCache : $cache]
            : [$classOrID, $idOrCache, $cache];

        // Validate class
        if ($class === self::class) {
            throw new InvalidArgumentException('DataObject::get_by_id() cannot query non-subclass DataObject directly');
        }

        // Pass to get_one
        $column = static::getSchema()->sqlColumnForField($class, 'ID');
        return DataObject::get_one($class, [$column => $id], $cached);
    }
public static function get_by_id($classOrID, $idOrCache = null, $cache = true)
    {
        // Shift arguments if passing id in first or second argument
        list ($class, $id, $cached) = is_numeric($classOrID)
            ? [get_called_class(), $classOrID, isset($idOrCache) ? $idOrCache : $cache]
            : [$classOrID, $idOrCache, $cache];

        // Validate class
        if ($class === self::class) {
            throw new InvalidArgumentException('DataObject::get_by_id() cannot query non-subclass DataObject directly');
        }

        // Pass to get_one
        $column = static::getSchema()->sqlColumnForField($class, 'ID');
        return DataObject::get_one($class, [$column => $id], $cached);
    }
public static function get_by_id ( $ classOrID , $ idOrCache = null , $ cache = true ) { // Shift arguments if passing id in first or second argument list ( $ class , $ id , $ cached ) = is_numeric ( $ classOrID ) ? [ get_called_class ( ) , $ classOrID , isset ( $ idOrCache ) ? $ idOrCache : $ cache ] : [ $ classOrID , $ idOrCache , $ cache ] ; // Validate class if ( $ class === self :: class ) { throw new InvalidArgumentException ( 'DataObject::get_by_id() cannot query non-subclass DataObject directly' ) ; } // Pass to get_one $ column = static :: getSchema ( ) -> sqlColumnForField ( $ class , 'ID' ) ; return DataObject :: get_one ( $ class , [ $ column => $ id ] , $ cached ) ; }
Return the given element, searching by ID.

This can be called either via `DataObject::get_by_id(MyClass::class, $id)`
or `MyClass::get_by_id($id)`

@param string|int $classOrID The class of the object to be returned, or id if called on target class
@param int|bool $idOrCache The id of the element, or cache if called on target class
@param boolean $cache See {@link get_one()}

@return static The element
Return the given element searching by ID .