DataObjectSchema
class DataObjectSchema
Provides {@link \SilverStripe\ORM\DataObject} and database schema mapping functionality
Traits
Constants
DB_ONLY |
fieldSpec should exclude virtual fields (such as composite fields), and only include fields with a db column. |
UNINHERITED |
fieldSpec should only return fields that belong to this table, and not any ancestors |
INCLUDE_CLASS |
fieldSpec should prefix all field specifications with the class name in RecordClass.Column(spec) format. |
Config options
table_namespace_separator | string | Default separate for table namespaces. Can be set to any string for databases that do not support some characters. |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
Gets the uninherited value for the given config option
Clear cached table names
Get all table names
Given a DataObject class and a field on that class, determine the appropriate SQL for selecting / filtering on in a SQL string. Note that $class must be a valid class, not an arbitrary table.
Get table name for the given class.
Returns the root class (the first to extend from DataObject) for the passed class.
Get the base table
Get all DB field specifications for a class, including ancestors and composite fields.
Get specifications for a single class field
Find the class for the given table
No description
Return the complete map of fields to specification on this object, including fixed_fields.
Gets a single database field.
No description
Check if the given class has a table
Returns a list of all the composite if the given db field on the class is a composite field.
Get a composite field for a class
Returns the table name in the class hierarchy which contains a given field column for a {@link DataObject}. If the field does not exist, this will return null.
Returns the class name in the class hierarchy which contains a given field column for a {@link DataObject}. If the field does not exist, this will return null.
Return information about a specific many_many component. Returns a numeric array.
Return the many-to-many extra fields specification for a specific component.
Return data for a specific has_many component.
Return data for a specific has_one component.
Return data for a specific belongs_to component.
Check class for any unary component
Tries to find the database key on another object that is used to store a relationship to this class. If no join field can be found it defaults to 'ParentID'.
Details
in Injectable at line 26
static Injectable
create(array $args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();
in Injectable at line 43
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
in Configurable at line 20
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in Configurable at line 32
mixed
stat(string $name)
deprecated
deprecated 5.0 Use ->config()->get() instead
Get inherited config value
in Configurable at line 44
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
in Configurable at line 57
$this
set_stat(string $name, mixed $value)
deprecated
deprecated 5.0 Use ->config()->set() instead
Update the config value for a given property
at line 72
reset()
Clear cached table names
at line 86
array
getTableNames()
Get all table names
at line 105
string
sqlColumnForField(string $class, string $field, string $tablePrefix = null)
Given a DataObject class and a field on that class, determine the appropriate SQL for selecting / filtering on in a SQL string. Note that $class must be a valid class, not an arbitrary table.
The result will be a standard ANSI-sql quoted string in "Table"."Column" format.
at line 124
string
tableName(string $class)
Get table name for the given class.
Note that this does not confirm a table actually exists (or should exist), but returns the name that would be used if this table did exist.
at line 143
string
baseDataClass(string|object $class)
Returns the root class (the first to extend from DataObject) for the passed class.
at line 163
string
baseDataTable(string|object $class)
Get the base table
at line 194
array
fieldSpecs(string|DataObject $classOrInstance, int $options)
Get all DB field specifications for a class, including ancestors and composite fields.
at line 246
string|null
fieldSpec(string|DataObject $classOrInstance, string $fieldName, int $options)
Get specifications for a single class field
at line 259
string|null
tableClass(string $table)
Find the class for the given table
at line 341
array
getLegacyTableNames($class)
at line 358
array
databaseFields(string $class, bool $aggregated = true)
Return the complete map of fields to specification on this object, including fixed_fields.
"ID" will be included on every table.
at line 385
string|null
databaseField(string $class, string $field, bool $aggregated = true)
Gets a single database field.
at line 397
array
databaseIndexes(string $class, bool $aggregated = true)
at line 418
bool
classHasTable(string $class)
Check if the given class has a table
at line 442
array
compositeFields(string $class, bool $aggregated = true)
Returns a list of all the composite if the given db field on the class is a composite field.
Will check all applicable ancestor classes and aggregate results.
Can be called directly on an object. E.g. Member::composite_fields(), or Member::composite_fields(null, true) to aggregate.
Includes composite has_one (Polymorphic) fields
at line 470
string|null
compositeField(string $class, string $field, bool $aggregated = true)
Get a composite field for a class
at line 692
string
tableForField(string $candidateClass, string $fieldName)
Returns the table name in the class hierarchy which contains a given field column for a {@link DataObject}. If the field does not exist, this will return null.
at line 711
string
classForField(string $candidateClass, string $fieldName)
Returns the class name in the class hierarchy which contains a given field column for a {@link DataObject}. If the field does not exist, this will return null.
at line 758
array|null
manyManyComponent(string $class, string $component)
Return information about a specific many_many component. Returns a numeric array.
The first item in the array will be the class name of the relation.
Standard many_many return type is:
array(
at line 849
array|null
manyManyExtraFieldsForComponent(string $class, string $component)
Return the many-to-many extra fields specification for a specific component.
at line 884
string|null
hasManyComponent(string $class, string $component, bool $classOnly = true)
Return data for a specific has_many component.
at line 908
string|null
hasOneComponent(string $class, string $component)
Return data for a specific has_one component.
at line 931
string|null
belongsToComponent(string $class, string $component, bool $classOnly = true)
Return data for a specific belongs_to component.
at line 957
string|null
unaryComponent(string $class, string $component)
Check class for any unary component
Alias for hasOneComponent() ?: belongsToComponent()
at line 1071
string
getRemoteJoinField(string $class, string $component, string $type = 'has_many', boolean $polymorphic = false)
Tries to find the database key on another object that is used to store a relationship to this class. If no join field can be found it defaults to 'ParentID'.
If the remote field is polymorphic then $polymorphic is set to true, and the return value is in the form 'Relation' instead of 'RelationID', referencing the composite DBField.