src/ORM/FieldType/DBField.php
public static function create_field($spec, $value, $name = null, ...$args)
    {
        // Raise warning if inconsistent with DataObject::dbObject() behaviour
        // This will cause spec args to be shifted down by the number of provided $args
        if ($args && strpos($spec, '(') !== false) {
            trigger_error('Additional args provided in both $spec and $args', E_USER_WARNING);
        }
        // Ensure name is always first argument
        array_unshift($args, $name);

        /** @var DBField $dbField */
        $dbField = Injector::inst()->createWithArgs($spec, $args);
        $dbField->setValue($value, null, false);
        return $dbField;
    }
public static function create_field($spec, $value, $name = null, ...$args)
    {
        // Raise warning if inconsistent with DataObject::dbObject() behaviour
        // This will cause spec args to be shifted down by the number of provided $args
        if ($args && strpos($spec, '(') !== false) {
            trigger_error('Additional args provided in both $spec and $args', E_USER_WARNING);
        }
        // Ensure name is always first argument
        array_unshift($args, $name);

        /** @var DBField $dbField */
        $dbField = Injector::inst()->createWithArgs($spec, $args);
        $dbField->setValue($value, null, false);
        return $dbField;
    }
public static function create_field ( $ spec , $ value , $ name = null , ... $ args ) { // Raise warning if inconsistent with DataObject::dbObject() behaviour // This will cause spec args to be shifted down by the number of provided $args if ( $ args && strpos ( $ spec , '(' ) !== false ) { trigger_error ( 'Additional args provided in both $spec and $args' , E_USER_WARNING ) ; } // Ensure name is always first argument array_unshift ( $ args , $ name ) ; /** @var DBField $dbField */ $ dbField = Injector :: inst ( ) -> createWithArgs ( $ spec , $ args ) ; $ dbField -> setValue ( $ value , null , false ) ; return $ dbField ; }
Create a DBField object that's not bound to any particular field.

Useful for accessing the classes behaviour for other parts of your code.

@param string $spec Class specification to construct. May include both service name and additional
constructor arguments in the same format as DataObject.db config.
@param mixed $value value of field
@param string $name Name of field
@param mixed $args Additional arguments to pass to constructor if not using args in service $spec
Note: Will raise a warning if using both
@return static
Create a DBField object that s not bound to any particular field .