Version: current

# Class DataObject

A single database record & abstract class for the data-access-model.

## Extensions and Decorators

See `Extension` and `DataObjectDecorator`.

## Permission Control

Object-level access control by `Permission`. Permission codes are arbitrary strings which can be selected on a group-by-group basis.

    class Article extends DataObject implements PermissionProvider {
            static $api_access = true;

            public function canView($member = false) {
                    return Permission::check('ARTICLE_VIEW');
            }
            public function canEdit($member = false) {
                    return Permission::check('ARTICLE_EDIT');
            }
            public function canDelete() {
                    return Permission::check('ARTICLE_DELETE');
            }
            public function canCreate() {
                    return Permission::check('ARTICLE_CREATE');
            }
            public function providePermissions() {
                    return array(
                            'ARTICLE_VIEW' => 'Read an article object',
                            'ARTICLE_EDIT' => 'Edit an article object',
                            'ARTICLE_DELETE' => 'Delete an article object',
                            'ARTICLE_CREATE' => 'Create an article object',
                    );
            }
    }

Object-level access control by `Group` membership:

    class Article extends DataObject {
            static $api_access = true;

            public function canView($member = false) {
                    if(!$member) $member = Member::currentUser();
            return $member->inGroup('Subscribers');
            }
            public function canEdit($member = false) {
                    if(!$member) $member = Member::currentUser();
            return $member->inGroup('Editors');
            }

            // ...
    }

If any public method on this class is prefixed with an underscore, the results are cached in memory through `ViewableData::cachedCall()`.

  Object
  ViewableData implements IteratorAggregate
  DataObject implements DataObjectInterface, i18nEntityProvider

### Direct known subclasses

`Address`, `BookingOrder`, `DocumentHaving`, `DocumentItem`, `DocumentPage_File`, `DocumentType`, `EditableFormField`, `EditableOption`, `Email_BounceRecord`, `Epitaph`, `FaqQuestion`, `File`, `BookingOrder_StatusLog`, `FlowerGarden`, `FlowerGarden_Size`, `Group`, `GuestbookEntry`, `Import1CLog`, `Import1CLog_File`, `Import1CLog_Item`, `Import1CLog_Task`, `ImportCatalog1C_PriceType`, `ImportCatalog1C_ProductProp`, `BookingPaymentMethod`, `LoginAttempt`, `LogItem`, `Material3D_File`, `MediawebPage_File`, `MediawebPage_Photo`, `Member`, `MemberPassword`, `MonumentGalleryItem`, `MonumentPhotoGallery`, `Newsletter`, `BookingService`, `Newsletter_Recipient`, `Newsletter_SentRecipient`, `NewsletterEmailBlacklist`, `NewsletterType`, `Notification`, `Order`, `Order_StatusLog`, `OrderDataObject`, `OrderItem`, `PageComment`, `CatalogFilter`, `Payment`, `PaymentMethod`, `PaymentType`, `Permission`, `PermissionRole`, `PermissionRoleCode`, `Person`, `PhotoAlbumItem`, `Polishing`, `Poll`, `CustomMenuHolder`, `PollAnswer`, `PortraitType`, `ProductImportLog`, `ProductImportLog_Item`, `ProductParam`, `ProductParamValue`, `ProductVariation`, `QueuedEmail`, `RatePeriod`, `RatingDataObject`, `CustomMenuItem`, `RealtyImportLog`, `RealtyImportLog_Item`, `RedirectEntry`, `RegionRestriction`, `RelatedPageLink`, `RoomOrder`, `RoomOrderPerson`, `RoomRate`, `ServiceOrder`, `ShippingMethod`, `DataObjectFileTracking`, `SimpleOrderData`, `SiteConfig`, `SiteTree`, `SocleSection`, `SubmittedForm`, `SubmittedFormField`, `Subsite`, `SubsiteDomain`, `Texture3D_File`, `UnsubscribeRecord`, `DocumentDirection`, `UserDefinedForm_EmailRecipient`, `VAT`, `VideoCategory`, `VideoEntry`, `VKNotificationQueue`, `WebylonWidget_Item`, `Widget`, `WidgetArea`

### Indirect known subclasses

`AdditionalMenuWidget`, `AdditionalMenuWidget_Item`, `BookingAdminPage`, `PhotoGalleryPage`, `PhotoGalleryWidget`, `PollSidebarWidget`, `PriceListWidget`, `Product`, `ProductSearchPage`, `ProfilePage`, `PublHolder`, `Publication`, `PublicationWidget`, `BookingPage`, `RedirectorPage`, `RegistrationPage`, `Room`, `RoomCatalog`, `RoomService`, `RoomServiceOrder`, `SberbankPayment`, `SearchWidget`, `SeparateHomepageWidget`, `SeparateSidebarWidget`, `ButtonsBlockHomepageWidget`, `SidebarWidget`, `SidebarWidgetArea`, `SimpleOrderForm`, `SimpleOrderPage`, `SliderHomepageWidget`, `SliderHomepageWidget_Item`, `Socle`, `SocleSize`, `SpecialCatalog`, `SpecialCatalogHomepageWidget`, `ButtonsBlockHomepageWidget_Item`, `SpecialCatalogSidebarWidget`, `StartCatalog`, `SubmittedFileField`, `SubscribeForm`, `SubscribeWidget`, `SubsectionMenuWidget`, `Subsite_Template`, `SubsitesSelectorPage`, `SubsitesVirtualPage`, `TableShippingMethod`, `CallBackWidget`, `TableShippingRate`, `TextAnonsWidget`, `TextAnonsWidget_Item`, `TextBlockHomepageWidget`, `TextBlockSidebarWidget`, `UnitellerPayment`, `UserDefinedForm`, `VideoBankPage`, `VideoFile`, `VirtualPage`, `CarouselHomepageWidget`, `VirtualProduct`, `WeatherSidebarWidget`, `WebylonWidget`, `WebylonWidgetArea`, `WeightTableShippingMethod`, `WeightTableShippingRate`, `YaMoneyPayment`, `YandexMapsHomepageWidget`, `YandexMapsWidget`, `CarouselHomepageWidget_Item`, `CartPage`, `CartWidget`, `Catalog`, `AdvancedSliderHomepageWidget`, `CatalogFilterSidebarWidget`, `CatalogRubricsHomepageWidget`, `CheckoutPage`, `ChequePayment`, `ConsultantWidget`, `ContactsBlockWidget`, `ContactsPage`, `CostTableShippingMethod`, `CostTableShippingRate`, `CurrencyWidget`, `AdvancedSliderHomepageWidget_Item`, `CustomPayment`, `DocPage`, `DocumentsPage`, `EditableCheckbox`, `EditableCheckboxGroupField`, `EditableCountryDropdownField`, `EditableDateField`, `EditableDateTimeField`, `EditableDropdown`, `EditableEmailField`, `Announcement`, `EditableFileField`, `EditableFormHeading`, `EditableHiddenField`, `EditableLiteralField`, `EditableMemberListField`, `EditableMultipleOptionField`, `EditableNumericField`, `EditablePhoneField`, `EditableRadioField`, `EditableSiteAgreementField`, `AnnouncementHolder`, `EditableSpamProtectionField`, `EditableTextField`, `EditableTimeField`, `ErrorPage`, `Event`, `EventCalendarWidget`, `EventHolder`, `FaqHolder`, `FAQHomepageWidget`, `FaqSection`, `AuthFormWidget`, `FAQSidebarWidget`, `FavoritePage`, `FavoriteProductsSidebarWidget`, `FeedbackHomepageWidget`, `FixedShippingMethod`, `FLV`, `Folder`, `Guestbook`, `GuestbookWidget`, `HomePage`, `BannerWidget`, `HomepageWidget`, `HomepageWidgetArea`, `HouseCatalogSearchWidget`, `HTMLBlockHomepageWidget`, `HTMLBlockSidebarWidget`, `Image`, `Image_Cached`, `MapObject`, `MapObjectGroup`, `MapPage`, `BannerWidget_Item`, `MediawebPage`, `MediawebPage_Image`, `Monument`, `MonumentCatalog`, `MonumentForm`, `MP3`, `NewsArchive`, `NewsEntry`, `NewsHolder`, `NewsHomepageWidget`, `BaseObjectCategory`, `NewsSidebarWidget`, `OrderService`, `OrderServiceOrder`, `Page`, `PageMenuWidget`, `PayPalPayment`, `PhotoAlbumHomepageWidget`, `PhotoAlbumPage`, `PhotoGalleryHomepageWidget`, `PhotoGalleryHomepageWidget_Item`

Package: sapphire\model
Located at sapphire/core/model/DataObject.php

## Methods summary

`public static boolean` | # `get_validation_enabled( )` Returns when validation on DataObjects is enabled. Returns when validation on DataObjects is enabled. #### Returns `boolean` bool
`public static` | # `set_validation_enabled( mixed $enable )` Set whether DataObjects should be validated before they are written. Set whether DataObjects should be validated before they are written. #### Parameters $enable $enable bool #### See ``DataObject::validate()``
`public static array` | # `database_fields( string $class )` Return the complete map of fields on this object, including Created, LastEdited and ClassName Return the complete map of fields on this object, including Created, LastEdited and ClassName #### Parameters $class string $class #### Returns `array` array
`public static array` | # `custom_database_fields( string $class )` Get all database columns explicitly defined on a class in `DataObject::$db` and `DataObject::$has_one`. Resolves instances of `CompositeDBField` into the actual database fields, rather than the name of the field which might not equate a database column. Get all database columns explicitly defined on a class in `DataObject::$db` and `DataObject::$has_one`. Resolves instances of `CompositeDBField` into the actual database fields, rather than the name of the field which might not equate a database column. #### Parameters $class string $class #### Returns `array` Map of fieldname to specification, similiar to `DataObject::$db`. #### Uses ``CompositeDBField::compositeDatabaseFields()``
`public static` | # `is_composite_field( mixed $class, mixed $name, mixed $aggregated = true )` Returns the field class if the given db field on the class is a composite field. Will check all applicable ancestor classes and aggregate results. Returns the field class if the given db field on the class is a composite field. Will check all applicable ancestor classes and aggregate results.
`public static` | # `composite_fields( mixed $class, mixed $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. 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.
`public static` | # `disableCMSFieldsExtensions( )` Stops extendCMSFields() being called on getCMSFields(). This is useful when you need access to fields added by subclasses of SiteTree in a decorator. Call before calling parent::getCMSFields(), and reenable afterwards. Stops extendCMSFields() being called on getCMSFields(). This is useful when you need access to fields added by subclasses of SiteTree in a decorator. Call before calling parent::getCMSFields(), and reenable afterwards.
`public static` | # `enableCMSFieldsExtensions( )` Reenables extendCMSFields() being called on getCMSFields() after it has been disabled by disableCMSFieldsExtensions(). Reenables extendCMSFields() being called on getCMSFields() after it has been disabled by disableCMSFieldsExtensions().
`public` | # `__construct( array|null $record = null, boolean $isSingleton = false )` Construct a new DataObject. Construct a new DataObject. #### Parameters $record array|null $record This will be null for a new database record. Alternatively, you can pass an array of field values. Normally this contructor is only used by the internal systems that get objects from the database. $isSingleton boolean $isSingleton This this to true if this is a singleton() object, a stub for calling methods. Singletons don't have their defaults set. #### Overrides `Object::__construct` #### Implementation of `DataObjectInterface::__construct()`
`public` | # `destroy( )` Destroy all of this objects dependant objects. You'll need to call this to get the memory of an object that has components or extensions freed. Destroy all of this objects dependant objects. You'll need to call this to get the memory of an object that has components or extensions freed.
`public `DataObject`` | # `duplicate( mixed $doWrite = true )` Create a duplicate of this node. Caution: Doesn't duplicate relations. Create a duplicate of this node. Caution: Doesn't duplicate relations. #### Parameters $doWrite $doWrite Perform a write() operation before returning the object. If this is true, it will create the duplicate in the database. #### Returns ``DataObject`` A duplicate of this node. The exact type will be the type of this node.
`public` | # `setClassName( string $className )` Set the ClassName attribute. `Object::$class` is also updated. Warning: This will produce an inconsistent record, as the object instance will not automatically switch to the new subclass. Please use `DataObject::newClassInstance()` for this purpose, or destroy and reinstanciate the record. Set the ClassName attribute. `Object::$class` is also updated. Warning: This will produce an inconsistent record, as the object instance will not automatically switch to the new subclass. Please use `DataObject::newClassInstance()` for this purpose, or destroy and reinstanciate the record. #### Parameters $className string $className The new ClassName attribute (a subclass of `DataObject`)
`public `DataObject`` | # `newClassInstance( string $newClassName )` Create a new instance of a different class from this object's record. This is useful when dynamically changing the type of an instance. Specifically, it ensures that the instance of the class is a match for the className of the record. Don't set the DataObject->class or DataObject->ClassName property manually before calling this method, as it will confuse change detection. Create a new instance of a different class from this object's record. This is useful when dynamically changing the type of an instance. Specifically, it ensures that the instance of the class is a match for the className of the record. Don't set the DataObject->class or DataObject->ClassName property manually before calling this method, as it will confuse change detection. If the new class is different to the original class, defaults are populated again because this will only occur automatically on instantiation of a DataObject if there is no record, or the record has no ID. In this case, we do have an ID but we still need to repopulate the defaults. #### Parameters $newClassName string $newClassName The name of the new class #### Returns ``DataObject`` The new instance of the new class, The exact type will be of the class name provided.
`public` | # `defineMethods( )` Adds methods from the extensions. Called by Object::__construct() once per class. Adds methods from the extensions. Called by Object::__construct() once per class. #### Overrides `ViewableData::defineMethods`
`public boolean` | # `exists( )` Returns true if this object "exists", i.e., has a sensible value. The default behaviour for a DataObject is to return true if the object exists in the database, you can override this in subclasses. Returns true if this object "exists", i.e., has a sensible value. The default behaviour for a DataObject is to return true if the object exists in the database, you can override this in subclasses. #### Returns `boolean` true if this object exists #### Overrides `Object::exists`
`public` | # `isEmpty( )`
`public string` | # `singular_name( )` Get the user friendly singular name of this DataObject. If the name is not defined (by redefining $singular_name in the subclass), this returns the class name. Get the user friendly singular name of this DataObject. If the name is not defined (by redefining $singular_name in the subclass), this returns the class name. #### Returns `string` User friendly singular name of this DataObject
`public string` | # `i18n_singular_name( )` Get the translated user friendly singular name of this DataObject same as singular_name() but runs it through the translating function Get the translated user friendly singular name of this DataObject same as singular_name() but runs it through the translating function Translating string is in the form: $this->class.SINGULARNAME Example: Page.SINGULARNAME #### Returns `string` User friendly translated singular name of this DataObject
`public string` | # `plural_name( )` Get the user friendly plural name of this DataObject If the name is not defined (by renaming $plural_name in the subclass), this returns a pluralised version of the class name. Get the user friendly plural name of this DataObject If the name is not defined (by renaming $plural_name in the subclass), this returns a pluralised version of the class name. #### Returns `string` User friendly plural name of this DataObject
`public string` | # `i18n_plural_name( )` Get the translated user friendly plural name of this DataObject Same as plural_name but runs it through the translation function Translation string is in the form: $this->class.PLURALNAME Example: Page.PLURALNAME Get the translated user friendly plural name of this DataObject Same as plural_name but runs it through the translation function Translation string is in the form: $this->class.PLURALNAME Example: Page.PLURALNAME #### Returns `string` User friendly translated plural name of this DataObject
`public string` | # `getTitle( )` Standard implementation of a title/label for a specific record. Tries to find properties 'Title' or 'Name', and falls back to the 'ID'. Useful to provide user-friendly identification of a record, e.g. in errormessages or UI-selections. Standard implementation of a title/label for a specific record. Tries to find properties 'Title' or 'Name', and falls back to the 'ID'. Useful to provide user-friendly identification of a record, e.g. in errormessages or UI-selections. Overload this method to have a more specialized implementation, e.g. for an Address record this could be:
    public function getTitle() {
      return "{$this->StreetNumber} {$this->StreetName} {$this->City}";
    }
#### Returns `string` string
`public `DataObject`` | # `data( )` Returns the associated database record - in this case, the object itself. This is included so that you can call $dataOrController->data() and get a DataObject all the time. Returns the associated database record - in this case, the object itself. This is included so that you can call $dataOrController->data() and get a DataObject all the time. #### Returns ``DataObject`` Associated database record
`public array` | # `toMap( )` Convert this object to a map. Convert this object to a map. #### Returns `array` The data as a map.
`public` | # `update( array $data )` Update a number of fields on this object, given a map of the desired changes. Update a number of fields on this object, given a map of the desired changes. The field names can be simple names, or you can use a dot syntax to access $has_one relations. For example, array("Author.FirstName" => "Jim") will set $this->Author()->FirstName to "Jim". update() doesn't write the main object, but if you use the dot syntax, it will write() the related objects that it alters. #### Parameters $data array $data A map of field name to data values to update.
`public` | # `castedUpdate( array $data )` Pass changes as a map, and try to get automatic casting for these fields. Doesn't write to the database. To write the data, use the write() method. Pass changes as a map, and try to get automatic casting for these fields. Doesn't write to the database. To write the data, use the write() method. #### Parameters $data array $data A map of field name to data values to update.
`public `Boolean`` | # `merge( mixed $rightObj, mixed $priority = 'right', mixed $includeRelations = true, mixed $overwriteWithEmpty = false )` Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty. has_one-relations are just transferred with priority 'right'. has_many and many_many-relations are added regardless of priority. Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty. has_one-relations are just transferred with priority 'right'. has_many and many_many-relations are added regardless of priority. Caution: has_many/many_many relations are moved rather than duplicated, meaning they are not connected to the merged object any longer. Caution: Just saves updated has_many/many_many relations to the database, doesn't write the updated object itself (just writes the object-properties). Caution: Does not delete the merged object. Caution: Does now overwrite Created date on the original object. #### Parameters $rightObj $obj DataObject $priority $priority String left|right Determines who wins in case of a conflict (optional) $includeRelations $includeRelations Boolean Merge any existing relations (optional) $overwriteWithEmpty $overwriteWithEmpty Boolean Overwrite existing left values with empty right values. Only applicable with $priority='right'. (optional) #### Returns ``Boolean`` Boolean
`public` | # `forceChange( )` Forces the record to think that all its data has changed. Doesn't write to the database. Only sets fields as changed if they are not already marked as changed. Forces the record to think that all its data has changed. Doesn't write to the database. Only sets fields as changed if they are not already marked as changed.
`protected A` | # `validate( )` Validate the current object. Validate the current object. By default, there is no validation - objects are always valid! However, you can overload this method in your DataObject sub-classes to specify custom validation. Invalid objects won't be able to be written - a warning will be thrown and no write will occur. onBeforeWrite() and onAfterWrite() won't get called either. It is expected that you call validate() in your own application to test that an object is valid before attempting a write, and respond appropriately if it isnt'. #### Returns `A` `ValidationResult` object
`protected` | # `onBeforeWrite( )` Event handler called before writing to the database. You can overload this to clean up or otherwise process data before writing it to the database. Don't forget to call parent::onBeforeWrite(), though! Event handler called before writing to the database. You can overload this to clean up or otherwise process data before writing it to the database. Don't forget to call parent::onBeforeWrite(), though! This called after $this->validate(), so you can be sure that your data is valid. #### Uses ``DataObjectDecorator::onBeforeWrite()``
`protected` | # `onAfterWrite( )` Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! #### Uses ``DataObjectDecorator::onAfterWrite()``
`protected` | # `onBeforeDelete( )` Event handler called before deleting from the database. You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though! Event handler called before deleting from the database. You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though! #### Uses ``DataObjectDecorator::onBeforeDelete()``
`protected` | # `onAfterDelete( )`
`public` | # `populateDefaults( )` Load the default values in from the self::$defaults array. Will traverse the defaults of the current class and all its parent classes. Called by the constructor when creating new records. Load the default values in from the self::$defaults array. Will traverse the defaults of the current class and all its parent classes. Called by the constructor when creating new records. #### Uses ``DataObjectDecorator::populateDefaults()``
`public integer` | # `write( boolean $showDebug = false, boolean $forceInsert = false, boolean $forceWrite = false, boolean $writeComponents = false )` Writes all changes to this object to the database. - It will insert a record whenever ID isn't set, otherwise update. - All relevant tables will be updated. - $this->onBeforeWrite() gets called beforehand. - Extensions such as Versioned will ammend the database-write to ensure that a version is saved. - Calls to `DataObjectLog` can be used to see everything that's been changed. Writes all changes to this object to the database. - It will insert a record whenever ID isn't set, otherwise update. - All relevant tables will be updated. - $this->onBeforeWrite() gets called beforehand. - Extensions such as Versioned will ammend the database-write to ensure that a version is saved. - Calls to `DataObjectLog` can be used to see everything that's been changed. #### Parameters $showDebug boolean $showDebug Show debugging information $forceInsert boolean $forceInsert Run INSERT command rather than UPDATE, even if record already exists $forceWrite boolean $forceWrite Write to database even if there are no changes $writeComponents boolean $writeComponents Call write() on all associated component instances which were previously retrieved through `DataObject::getComponent()`, `DataObject::getComponents()` or `DataObject::getManyManyComponents()` (Default: false) #### Returns `integer` The ID of the record #### Throws ``ValidationException`` Exception that can be caught and handled by the calling function #### Uses ``DataObjectDecorator::augmentWrite()`` #### Implementation of `DataObjectInterface::write()`
`public` | # `writeComponents( mixed $recursive = false )` Write the cached components to the database. Cached components could refer to two different instances of the same record. Write the cached components to the database. Cached components could refer to two different instances of the same record. #### Parameters $recursive $recursive Recursively write components
`public integer` | # `writeWithoutVersion( )` Perform a write without affecting the version table. On objects without versioning. Perform a write without affecting the version table. On objects without versioning. #### Returns `integer` The ID of the record
`public` | # `delete( )` Delete this data object. $this->onBeforeDelete() gets called. Note that in Versioned objects, both Stage and Live will be deleted. Delete this data object. $this->onBeforeDelete() gets called. Note that in Versioned objects, both Stage and Live will be deleted. #### Uses ``DataObjectDecorator::augmentSQL()`` #### Implementation of `DataObjectInterface::delete()`
`public static` | # `delete_by_id( string $className, integer $id )` Delete the record with the given ID. Delete the record with the given ID. #### Parameters $className string $className The class name of the record to be deleted $id int $id ID of record to be deleted
`public array` | # `getClassAncestry( )` Get the class ancestry, including the current class name. The ancestry will be returned as an array of class names, where the 0th element will be the class that inherits directly from DataObject, and the last element will be the current class. Get the class ancestry, including the current class name. The ancestry will be returned as an array of class names, where the 0th element will be the class that inherits directly from DataObject, and the last element will be the current class. #### Returns `array` Class ancestry
`public `DataObject`` | # `getComponent( string $componentName )` Return a component object from a one to one relationship, as a DataObject. If no component is available, an 'empty component' will be returned. Return a component object from a one to one relationship, as a DataObject. If no component is available, an 'empty component' will be returned. #### Parameters $componentName string $componentName Name of the component #### Returns ``DataObject`` The component object. It's exact type will be that of the component.
`public `ComponentSet`` | # `getComponents( string $componentName, string $filter = "", string|array $sort = "", string $join = "", string|array $limit = "" )` Returns a one-to-many component, as a ComponentSet. Returns a one-to-many component, as a ComponentSet. #### Parameters $componentName string $componentName Name of the component $filter string $filter A filter to be inserted into the WHERE clause $sort string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, the static field $default_sort on the component class will be used. $join string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned. $limit string|array $limit A limit expression to be inserted into the LIMIT clause #### Returns ``ComponentSet`` The components of the one-to-many relationship.
`public `SQLQuery`` | # `getComponentsQuery( string $componentName, string $filter = "", string|array $sort = "", string $join = "", string|array $limit = "" )` Get the query object for a $has_many Component. Get the query object for a $has_many Component. Use DataObjectSet->setComponentInfo() to attach metadata to the resultset you're building with this query. Use DataObject->buildDataObjectSet() to build a set out of the `SQLQuery` object, and pass "ComponentSet" as a $containerClass. #### Parameters $componentName string $componentName $filter string $filter $sort string|array $sort $join string $join $limit string|array $limit #### Returns ``SQLQuery`` SQLQuery
`public string` | # `getRemoteJoinField( string $component, string $type = 'has_many' )` 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'. 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'. #### Parameters $component string $component $type string $type the join type - either 'has_many' or 'belongs_to' #### Returns `string` string
`public` | # `setComponent( string $componentName, `DataObject`|`ComponentSet` $componentValue )` Sets the component of a relationship. Sets the component of a relationship. #### Parameters $componentName string $componentName Name of the component $componentValue DataObject|ComponentSet $componentValue Value of the component
`public `ComponentSet`` | # `getManyManyComponents( string $componentName, mixed $filter = "", mixed $sort = "", mixed $join = "", mixed $limit = "" )` Returns a many-to-many component, as a ComponentSet. Returns a many-to-many component, as a ComponentSet. #### Parameters $componentName string $componentName Name of the many-many component $filter $sort $join $limit #### Returns ``ComponentSet`` The set of components
`public `SQLQuery`` | # `getManyManyComponentsQuery( string $componentName, string $filter = "", string|array $sort = "", string $join = "", string|array $limit = "" )` Get the query object for a $many_many Component. Use DataObjectSet->setComponentInfo() to attach metadata to the resultset you're building with this query. Use DataObject->buildDataObjectSet() to build a set out of the `SQLQuery` object, and pass "ComponentSet" as a $containerClass. Get the query object for a $many_many Component. Use DataObjectSet->setComponentInfo() to attach metadata to the resultset you're building with this query. Use DataObject->buildDataObjectSet() to build a set out of the `SQLQuery` object, and pass "ComponentSet" as a $containerClass. #### Parameters $componentName string $componentName $filter string $filter $sort string|array $sort $join string $join $limit string|array $limit #### Returns ``SQLQuery`` SQLQuery
`public string` | # `getManyManyJoin( string $componentName, string $baseTable )` Pull out a join clause for a many-many relationship. Pull out a join clause for a many-many relationship. #### Parameters $componentName string $componentName The many_many or belongs_many_many relation to join to. $baseTable string $baseTable The classtable that will already be included in the SQL query to which this join will be added. #### Returns `string` SQL join clause
`public` | # `getManyManyFilter( mixed $componentName, mixed $baseTable )`
`public` | # `Aggregate( mixed $type = null, mixed $filter = '' )` Return an aggregate object. An aggregate object returns the result of running some SQL aggregate function on a field of this dataobject type. Return an aggregate object. An aggregate object returns the result of running some SQL aggregate function on a field of this dataobject type. It can be called with no arguments, in which case it returns an object that calculates aggregates on this object's type, or with an argument (possibly statically), in which case it returns an object for that type
`public` | # `RelationshipAggregate( mixed $object = null, mixed $relationship = '', mixed $filter = '' )` Return an relationship aggregate object. A relationship aggregate does the same thing as an aggregate object, but operates on a has_many rather than directly on the type specified Return an relationship aggregate object. A relationship aggregate does the same thing as an aggregate object, but operates on a has_many rather than directly on the type specified
`public string|array` | # `has_one( string $component = null )` Return the class of a one-to-one component. If $component is null, return all of the one-to-one components and their classes. Return the class of a one-to-one component. If $component is null, return all of the one-to-one components and their classes. #### Parameters $component string $component Name of component #### Returns `string|array` The class of the one-to-one component, or an array of all one-to-one components and their classes.
`public string|array` | # `belongs_to( string $component = null, boolean $classOnly = true )` Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned. Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned. #### Parameters $component string $component $classOnly bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE. #### Returns `string|array` string|array
`public array` | # `db( string $fieldName = null )` Return all of the database fields defined in self::$db and all the parent classes. Doesn't include any fields specified by self::$has_one. Use $this->has_one() to get these fields Return all of the database fields defined in self::$db and all the parent classes. Doesn't include any fields specified by self::$has_one. Use $this->has_one() to get these fields #### Parameters $fieldName string $fieldName Limit the output to a specific field name #### Returns `array` The database fields
`public string|array` | # `has_many( string $component = null, boolean $classOnly = true )` Gets the class of a one-to-many relationship. If no $component is specified then an array of all the one-to-many relationships and their classes will be returned. Gets the class of a one-to-many relationship. If no $component is specified then an array of all the one-to-many relationships and their classes will be returned. #### Parameters $component string $component Name of component $classOnly bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE. #### Returns `string|array` string|array
`public array` | # `many_many_extraFields( string $component = null )` Return the many-to-many extra fields specification. Return the many-to-many extra fields specification. If you don't specify a component name, it returns all extra fields for all components available. #### Parameters $component string $component Name of component #### Returns `array` array
`public array` | # `many_many( string $component = null )` Return information about a many-to-many component. The return value is an array of (parentclass, childclass). If $component is null, then all many-many components are returned. Return information about a many-to-many component. The return value is an array of (parentclass, childclass). If $component is null, then all many-many components are returned. #### Parameters $component string $component Name of component #### Returns `array` An array of (parentclass, childclass), or an array of all many-many components
`public array` | # `database_extensions( mixed $class )` This returns an array (if it exists) describing the database extensions that are required, or false if none This returns an array (if it exists) describing the database extensions that are required, or false if none This is experimental, and is currently only a Postgres-specific enhancement. #### Returns `array` or false
`public `SearchContext`` | # `getDefaultSearchContext( )` Generates a SearchContext to be used for building and processing a generic search form for properties on this object. Generates a SearchContext to be used for building and processing a generic search form for properties on this object. #### Returns ``SearchContext`` SearchContext
`public `FieldSet`` | # `scaffoldSearchFields( array $_params = null )` Determine which properties on the DataObject are searchable, and map them to their default `FormField` representations. Used for scaffolding a searchform for `ModelAdmin`. Determine which properties on the DataObject are searchable, and map them to their default `FormField` representations. Used for scaffolding a searchform for `ModelAdmin`. Some additional logic is included for switching field labels, based on how generic or specific the field type is. Used by `SearchContext`. #### Parameters $_params array $_params 'fieldClasses': Associative array of field names as keys and FormField classes as values 'restrictFields': Numeric array of a field name whitelist #### Returns ``FieldSet`` FieldSet
`public `FieldSet`` | # `scaffoldFormFields( array $_params = null )` Scaffold a simple edit form for all properties on this dataobject, based on default `FormField` mapping in `DBField::scaffoldFormField()`. Field labels/titles will be auto generated from `DataObject::fieldLabels()`. Scaffold a simple edit form for all properties on this dataobject, based on default `FormField` mapping in `DBField::scaffoldFormField()`. Field labels/titles will be auto generated from `DataObject::fieldLabels()`. #### Parameters $_params array $_params Associative array passing through properties to `FormScaffolder`. #### Returns ``FieldSet`` FieldSet #### Uses ``FormScaffolder``
`public `FieldSet`` | # `getCMSFields( array $params = null )` Centerpiece of every data administration interface in Silverstripe, which returns a `FieldSet` suitable for a `Form` object. If not overloaded, we're using `DataObject::scaffoldFormFields()` to automatically generate this set. To customize, overload this method in a subclass or decorate onto it by using DataObjectDecorator->updateCMSFields(). Centerpiece of every data administration interface in Silverstripe, which returns a `FieldSet` suitable for a `Form` object. If not overloaded, we're using `DataObject::scaffoldFormFields()` to automatically generate this set. To customize, overload this method in a subclass or decorate onto it by using DataObjectDecorator->updateCMSFields().
    klass MyCustomClass extends DataObject {
            static $db = array('CustomProperty'=>'Boolean');

            public function getCMSFields() {
                    $fields = parent::getCMSFields();
                    $fields->addFieldToTab('Root.Content',new CheckboxField('CustomProperty'));
            return $fields;
    }
    }
#### Parameters $params array $params See `DataObject::scaffoldFormFields()` #### Returns ``FieldSet`` Returns a TabSet for usage within the CMS - don't use for frontend forms. #### See Good example of complex FormField building: SiteTree::getCMSFields()
`public an` | # `getCMSActions( )` need to be overload by solid dataobject, so that the customised actions of that dataobject, including that dataobject's decorator customised actions could be added to the EditForm. need to be overload by solid dataobject, so that the customised actions of that dataobject, including that dataobject's decorator customised actions could be added to the EditForm. #### Returns `an` Empty FieldSet(); need to be overload by solid subclass
`public `FieldSet`` | # `getFrontEndFields( array $params = null )` Used for simple frontend forms without relation editing or `TabSet` behaviour. Uses `DataObject::scaffoldFormFields()` by default. To customize, either overload this method in your subclass, or decorate it by DataObjectDecorator->updateFrontEndFields(). Used for simple frontend forms without relation editing or `TabSet` behaviour. Uses `DataObject::scaffoldFormFields()` by default. To customize, either overload this method in your subclass, or decorate it by DataObjectDecorator->updateFrontEndFields(). #### Parameters $params array $params See `DataObject::scaffoldFormFields()` #### Returns ``FieldSet`` Always returns a simple field collection without TabSet.
`public mixed` | # `getField( string $field )` Gets the value of a field. Called by `ViewableData::__get()` and any getFieldName() methods you might create. Gets the value of a field. Called by `ViewableData::__get()` and any getFieldName() methods you might create. #### Parameters $field string $field The name of the field #### Returns `mixed` The field value #### Overrides `ViewableData::getField`
`public array` | # `getAllFields( )` Return a map of all the fields for this record. Return a map of all the fields for this record. #### Returns `array` A map of field names to field values.
`public array` | # `getChangedFields( boolean $databaseFieldsOnly = false, integer $changeLevel = 1 )` Return the fields that have changed. Return the fields that have changed. The change level affects what the functions defines as "changed": Level 1 will return strict changes, even !== ones. Level 2 is more lenient, it will only return real data changes, for example a change from 0 to null would not be included. Example return:
    array(
      'Title' = array('before' => 'Home', 'after' => 'Home-Changed', 'level' => 2)
    )
#### Parameters $databaseFieldsOnly boolean $databaseFieldsOnly Get only database fields that have changed $changeLevel int $changeLevel The strictness of what is defined as change #### Returns `array` array
`public boolean` | # `isChanged( string $fieldName = null, integer $changeLevel = 1 )` Uses `DataObject::getChangedFields()` to determine if fields have been changed since loading them from the database. Uses `DataObject::getChangedFields()` to determine if fields have been changed since loading them from the database. #### Parameters $fieldName string $fieldName Name of the database field to check, will check for any if not given $changeLevel int $changeLevel See `DataObject::getChangedFields()` #### Returns `boolean` boolean
`public` | # `setField( string $fieldName, mixed $val )` Set the value of the field Called by `ViewableData::__set()` and any setFieldName() methods you might create. Set the value of the field Called by `ViewableData::__set()` and any setFieldName() methods you might create. #### Parameters $fieldName string $fieldName Name of the field $val mixed $val New field value #### Overrides `ViewableData::setField`
`public` | # `setCastedField( string $fieldName, mixed $val )` Set the value of the field, using a casting object. This is useful when you aren't sure that a date is in SQL format, for example. setCastedField() can also be used, by forms, to set related data. For example, uploaded images can be saved into the Image table. Set the value of the field, using a casting object. This is useful when you aren't sure that a date is in SQL format, for example. setCastedField() can also be used, by forms, to set related data. For example, uploaded images can be saved into the Image table. #### Parameters $fieldName string $fieldName Name of the field $val mixed $value New field value #### Implementation of `DataObjectInterface::setCastedField()`
`public boolean` | # `hasField( string $field )` Returns true if the given field exists in a database column on any of the objects tables, or as a dynamic getter with get<fieldName>(). Returns true if the given field exists in a database column on any of the objects tables, or as a dynamic getter with get<fieldName>(). #### Parameters $field string $field Name of the field #### Returns `boolean` True if the given field exists #### Overrides `ViewableData::hasField`
`public boolean` | # `hasDatabaseField( string $field )` Returns true if the given field exists as a database column Returns true if the given field exists as a database column #### Parameters $field string $field Name of the field #### Returns `boolean` boolean
`public string` | # `hasOwnTableDatabaseField( string $field )` Returns the field type of the given field, if it belongs to this class, and not a parent. Note that the field type will not include constructor arguments in round brackets, only the classname. Returns the field type of the given field, if it belongs to this class, and not a parent. Note that the field type will not include constructor arguments in round brackets, only the classname. #### Parameters $field string $field Name of the field #### Returns `string` The field type of the given field
`public static boolean` | # `has_own_table( string $dataClass )` Returns true if given class has its own table. Uses the rules for whether the table should exist rather than actually looking in the database. Returns true if given class has its own table. Uses the rules for whether the table should exist rather than actually looking in the database. #### Parameters $dataClass string $dataClass #### Returns `boolean` bool
`public boolean` | # `can( string $perm, `Member` $member = null )` Returns true if the member is allowed to do the given action. Returns true if the member is allowed to do the given action. #### Parameters $perm string $perm The permission to be checked, such as 'View'. $member Member $member The member whose permissions need checking. Defaults to the currently logged in user. #### Returns `boolean` True if the the member is allowed to do the given action
`public boolean` | # `canView( `Member` $member = null )` #### Parameters $member Member $member #### Returns `boolean` boolean
`public boolean` | # `canEdit( `Member` $member = null )` #### Parameters $member Member $member #### Returns `boolean` boolean
`public boolean` | # `canDelete( `Member` $member = null )` #### Parameters $member Member $member #### Returns `boolean` boolean
`public boolean` | # `canCreate( `Member` $member = null )` #### Parameters $member Member $member #### Returns `boolean` boolean
`public string` | # `debug( )` Debugging used by Debug::show() Debugging used by Debug::show() #### Returns `string` HTML data representing this object
`public `DBField`` | # `dbObject( string $fieldName )` Return the DBField object that represents the given field. This works similarly to obj() with 2 key differences: - it still returns an object even when the field has no value. - it only matches fields and not methods - it matches foreign keys generated by has_one relationships, eg, "ParentID" Return the DBField object that represents the given field. This works similarly to obj() with 2 key differences: - it still returns an object even when the field has no value. - it only matches fields and not methods - it matches foreign keys generated by has_one relationships, eg, "ParentID" #### Parameters $fieldName string $fieldName Name of the field #### Returns ``DBField`` The field as a DBField object
`public `DBField`` | # `relObject( mixed $fieldPath )` Traverses to a DBField referenced by relationships between data objects. The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName) Traverses to a DBField referenced by relationships between data objects. The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName) #### Parameters $fieldPath $fieldPath string #### Returns ``DBField`` DBField
`public String` | # `getReverseAssociation( mixed $className )` Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys. Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys. #### Returns `String` String
`public `SQLQuery`` | # `buildSQL( string $filter = "", string|array $sort = "", string|array $limit = "", string $join = "", boolean $restrictClasses = true, string $having = "" )` Build a `SQLQuery` object to perform the given query. Build a `SQLQuery` object to perform the given query. #### Parameters $filter string $filter A filter to be inserted into the WHERE clause. $sort string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used. $limit string|array $limit A limit expression to be inserted into the LIMIT clause. $join string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned. $restrictClasses boolean $restictClasses Restrict results to only objects of either this class of a subclass of this class $having string $having A filter to be inserted into the HAVING clause. #### Returns ``SQLQuery`` Query built.
`public `SQLQuery`` | # `extendedSQL( string $filter = "", string|array $sort = "", string|array $limit = "", string $join = "", string $having = "" )` Like `DataObject::buildSQL()`, but applies the extension modifications. Like `DataObject::buildSQL()`, but applies the extension modifications. #### Parameters $filter string $filter A filter to be inserted into the WHERE clause. $sort string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used. $limit string|array $limit A limit expression to be inserted into the LIMIT clause. $join string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned. $having string $having A filter to be inserted into the HAVING clause. #### Returns ``SQLQuery`` Query built #### Uses ``DataObjectDecorator::augmentSQL()``
`public static mixed` | # `get( string $callerClass, string $filter = "", string|array $sort = "", string $join = "", string|array $limit = "", string $containerClass = "DataObjectSet" )` Return all objects matching the filter sub-classes are automatically selected and included Return all objects matching the filter sub-classes are automatically selected and included #### Parameters $callerClass string $callerClass The class of objects to be returned $filter string $filter A filter to be inserted into the WHERE clause. $sort string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used. $join string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned. $limit string|array $limit A limit expression to be inserted into the LIMIT clause. $containerClass string $containerClass The container class to return the results in. #### Returns `mixed` The objects matching the filter, in the class specified by $containerClass
`public mixed` | # `instance_get( string $filter = "", string $sort = "", string $join = "", string $limit = "", string $containerClass = "DataObjectSet" )` The internal function that actually performs the querying for get(). DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter") The internal function that actually performs the querying for get(). DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter") #### Parameters $filter string $filter A filter to be inserted into the WHERE clause. $sort string $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used. $join string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned. $limit string $limit A limit expression to be inserted into the LIMIT clause. $containerClass string $containerClass The container class to return the results in. #### Returns `mixed` The objects matching the filter, in the class specified by $containerClass #### Implementation of `DataObjectInterface::instance_get()`
`public mixed` | # `buildDataObjectSet( `SS_Query`|array $records, string $containerClass = "DataObjectSet", mixed $query = null, mixed $baseClass = null )` Take a database `SS_Query` and instanciate an object for each record. Take a database `SS_Query` and instanciate an object for each record. #### Parameters $records SS_Query|array $records The database records, a `SS_Query` object or an array of maps. $containerClass string $containerClass The class to place all of the objects into. $query $baseClass #### Returns `mixed` The new objects in an object of type $containerClass
`public static `DataObject`` | # `get_one( string $callerClass, string $filter = "", boolean $cache = true, string $orderby = "" )` Return the first item matching the given query. All calls to get_one() are cached. Return the first item matching the given query. All calls to get_one() are cached. #### Parameters $callerClass string $callerClass The class of objects to be returned $filter string $filter A filter to be inserted into the WHERE clause $cache boolean $cache Use caching $orderby string $orderby A sort expression to be inserted into the ORDER BY clause. #### Returns ``DataObject`` The first item matching the query
`public` | # `flushCache( boolean $persistant = true )` Flush the cached results for all relations (has_one, has_many, many_many) Also clears any cached aggregate data Flush the cached results for all relations (has_one, has_many, many_many) Also clears any cached aggregate data #### Parameters $persistant boolean $persistant When true will also clear persistant data stored in the Cache system. When false will just clear session-local cached data
`public static` | # `flush_and_destroy_cache( )`
`public static` | # `reset( )` Reset internal caches, for example after test runs Reset internal caches, for example after test runs
`public `DataObject`` | # `instance_get_one( string $filter, string $orderby = null )` Does the hard work for get_one() Does the hard work for get_one() #### Parameters $filter string $filter A filter to be inserted into the WHERE clause $orderby string $orderby A sort expression to be inserted into the ORDER BY clause. #### Returns ``DataObject`` The first item matching the query #### Uses ``DataObjectDecorator::augmentSQL()`` #### Implementation of `DataObjectInterface::instance_get_one()`
`public static `DataObject`` | # `get_by_id( string $callerClass, integer $id, boolean $cache = true )` Return the given element, searching by ID Return the given element, searching by ID #### Parameters $callerClass string $callerClass The class of the object to be returned $id int $id The id of the element $cache boolean $cache See `DataObject::get_one()` #### Returns ``DataObject`` The element
`public` | # `baseTable( )` Get the name of the base table for this object Get the name of the base table for this object
`public` | # `databaseIndexes( )` Return the database indexes on this table. This array is indexed by the name of the field with the index, and the value is the type of index. Return the database indexes on this table. This array is indexed by the name of the field with the index, and the value is the type of index.
`public` | # `requireTable( )` Check the database schema and update it as necessary. Check the database schema and update it as necessary. #### Uses ``DataObjectDecorator::augmentDatabase()``
`public` | # `requireDefaultRecords( )` Add default records to database. This function is called whenever the database is built, after the database tables have all been created. Overload this to add default records when the database is built, but make sure you call parent::requireDefaultRecords(). Add default records to database. This function is called whenever the database is built, after the database tables have all been created. Overload this to add default records when the database is built, but make sure you call parent::requireDefaultRecords(). #### Uses ``DataObjectDecorator::requireDefaultRecords()``
`public` | # `databaseFields( )` #### See ``DataObject::database_fields()``
`public` | # `customDatabaseFields( )` #### See ``DataObject::custom_database_fields()``
`public` | # `inheritedDatabaseFields( )` Returns fields bu traversing the class heirachy in a bottom-up direction. Returns fields bu traversing the class heirachy in a bottom-up direction. Needed to avoid getCMSFields being empty when customDatabaseFields overlooks the inheritance chain of the $db array, where a child data object has no $db array, but still needs to know the properties of its parent. This should be merged into databaseFields or customDatabaseFields.
`public array` | # `searchableFields( )` Get the default searchable fields for this object, as defined in the $searchable_fields list. If searchable fields are not defined on the data object, uses a default selection of summary fields. Get the default searchable fields for this object, as defined in the $searchable_fields list. If searchable fields are not defined on the data object, uses a default selection of summary fields. #### Returns `array` array
`public array|string` | # `fieldLabels( boolean $includerelations = true )` Get any user defined searchable fields labels that exist. Allows overriding of default field names in the form interface actually presented to the user. Get any user defined searchable fields labels that exist. Allows overriding of default field names in the form interface actually presented to the user. The reason for keeping this separate from searchable_fields, which would be a logical place for this functionality, is to avoid bloating and complicating the configuration array. Currently much of this system is based on sensible defaults, and this property would generally only be set in the case of more complex relationships between data object being required in the search interface. Generates labels based on name of the field itself, if no static property `DataObject::$field_labels` exists. #### Parameters $includerelations boolean $includerelations a boolean value to indicate if the labels returned include relation fields #### Returns `array|string` Array of all element labels if no argument given, otherwise the label of the field #### Uses `mixed` ``FormField::name_to_label()`` #### Used by ``DataObject::fieldLabel()`` ``FormScaffolder``
`public string` | # `fieldLabel( string $name )` Get a human-readable label for a single field, see `DataObject::fieldLabels()` for more details. Get a human-readable label for a single field, see `DataObject::fieldLabels()` for more details. #### Parameters $name string $name Name of the field #### Returns `string` Label of the field #### Uses ``DataObject::fieldLabels()`` ``FormField::name_to_label()``
`public array` | # `summaryFields( )` Get the default summary fields for this object. Get the default summary fields for this object. #### Returns `array` array
`public array` | # `defaultSearchFilters( )` Defines a default list of filters for the search context. Defines a default list of filters for the search context. If a filter class mapping is defined on the data object, it is constructed here. Otherwise, the default filter specified in `DBField` is used. #### Returns `array` array
`public boolean` | # `isInDB( )` #### Returns `boolean` True if the object is in the database
`public static` | # `set_context_obj( mixed $obj )` Sets a 'context object' that can be used to provide hints about how to process a particular get / get_one request. In particular, DataObjectDecorators can use this to amend queries more effectively. Care must be taken to unset the context object after you're done with it, otherwise you will have a stale context, which could cause horrible bugs. Sets a 'context object' that can be used to provide hints about how to process a particular get / get_one request. In particular, DataObjectDecorators can use this to amend queries more effectively. Care must be taken to unset the context object after you're done with it, otherwise you will have a stale context, which could cause horrible bugs.
`public static` | # `context_obj( )` Retrieve the current context object. Retrieve the current context object.
`public static` | # `disable_subclass_access( )` Temporarily disable subclass access in data object qeur Temporarily disable subclass access in data object qeur
`public static` | # `enable_subclass_access( )`
`public array` | # `provideI18nEntities( )` Collect all static properties on the object which contain natural language, and need to be translated. The full entity name is composed from the class name and a custom identifier. Collect all static properties on the object which contain natural language, and need to be translated. The full entity name is composed from the class name and a custom identifier. #### Returns `array` A numerical array which contains one or more entities in array-form. Each numeric entity array contains the "arguments" for a _t() call as array values: $entity, $string, $priority, $context. #### Implementation of `i18nEntityProvider::provideI18nEntities()`
`public boolean` | # `hasValue( string $field, array $arguments = null, boolean $cache = true )` Returns true if the given method/parameter has a value (Uses the DBField::hasValue if the parameter is a database field) Returns true if the given method/parameter has a value (Uses the DBField::hasValue if the parameter is a database field) #### Parameters $field string $field The field name $arguments array $arguments $cache bool $cache #### Returns `boolean` boolean #### Overrides `ViewableData::hasValue`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `escapeTypeForField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`public static string` | $singular_name | # Human-readable singular name. Human-readable singular name.
`public static string` | $plural_name | # Human-readable pluaral name Human-readable pluaral name
`public static boolean` | $api_access | # Allow API access to this object? Allow API access to this object?
`public static array` | $cache_has_own_table | #
`public static array` | $cache_has_own_table_field | #
`public boolean` | $destroyed | # True if this DataObject has been destroyed. True if this DataObject has been destroyed.
`protected array` | $record | # Data stored in this objects database record. An array indexed by fieldname. Data stored in this objects database record. An array indexed by fieldname.
`protected array` | $original | # The database record (in the same format as $record), before any changes. The database record (in the same format as $record), before any changes.
`protected array` | $components | # The one-to-one, one-to-many and many-to-one components indexed by component name. The one-to-one, one-to-many and many-to-one components indexed by component name.
`protected boolean` | $brokenOnDelete | # Used by onBeforeDelete() to ensure child classes call parent::onBeforeDelete() Used by onBeforeDelete() to ensure child classes call parent::onBeforeDelete()
`protected boolean` | $brokenOnWrite | # Used by onBeforeWrite() to ensure child classes call parent::onBeforeWrite() Used by onBeforeWrite() to ensure child classes call parent::onBeforeWrite()
`protected static array` | $ancestry | # A cache used by getClassAncestry() A cache used by getClassAncestry()
`protected array` | $componentCache | # A cache used by component getting classes A cache used by component getting classes
`protected static array` | $cache_get_one | # A cache used by get_one. A cache used by get_one.
`public static array` | $db | # Database field definitions. This is a map from field names to field type. The field type should be a class that extends . Database field definitions. This is a map from field names to field type. The field type should be a class that extends .
`public static array` | $casting | # Use a casting object for a field. This is a map from field name to class name of the casting object. Use a casting object for a field. This is a map from field name to class name of the casting object.
`public static array` | $create_table_options | # Specify custom options for a CREATE TABLE call. Can be used to specify a custom storage engine for specific database table. All options have to be keyed for a specific database implementation, identified by their class name (extending from `SS_Database`). Specify custom options for a CREATE TABLE call. Can be used to specify a custom storage engine for specific database table. All options have to be keyed for a specific database implementation, identified by their class name (extending from `SS_Database`).
    array(
            'MySQLDatabase' => 'ENGINE=MyISAM'
    )
Caution: This API is experimental, and might not be included in the next major release. Please use with care.
`public static array` | $indexes | # If a field is in this array, then create a database index on that field. This is a map from fieldname to index type. See SS_Database->requireIndex() and custom subclasses for details on the array notation. If a field is in this array, then create a database index on that field. This is a map from fieldname to index type. See SS_Database->requireIndex() and custom subclasses for details on the array notation.
`public static array` | $defaults | # Inserts standard column-values when a DataObject is instanciated. Does not insert default records `DataObject::$default_records`. This is a map from fieldname to default value. Inserts standard column-values when a DataObject is instanciated. Does not insert default records `DataObject::$default_records`. This is a map from fieldname to default value. If you would like to change a default value in a sub-class, just specify it. - If you would like to disable the default value given by a parent class, set the default value to 0,'',or false in your subclass. Setting it to null won't work.
`public static array` | $default_records | # Multidimensional array which inserts default data into the database on a db/build-call as long as the database-table is empty. Please use this only for simple constructs, not for SiteTree-Objects etc. which need special behaviour such as publishing and ParentNodes. Multidimensional array which inserts default data into the database on a db/build-call as long as the database-table is empty. Please use this only for simple constructs, not for SiteTree-Objects etc. which need special behaviour such as publishing and ParentNodes. Example: array( array('Title' => "DefaultPage1", 'PageTitle' => 'page1'), array('Title' => "DefaultPage2") ).
`public static array` | $has_one | # One-to-zero relationship defintion. This is a map of component name to data type. In order to turn this into a true one-to-one relationship you can add a `DataObject::$belongs_to` relationship on the child class. One-to-zero relationship defintion. This is a map of component name to data type. In order to turn this into a true one-to-one relationship you can add a `DataObject::$belongs_to` relationship on the child class. Note that you cannot have a has_one and belongs_to relationship with the same name.
`public static array` | $belongs_to | # A meta-relationship that allows you to define the reverse side of a `DataObject::$has_one`. A meta-relationship that allows you to define the reverse side of a `DataObject::$has_one`. This does not actually create any data structures, but allows you to query the other object in a one-to-one relationship from the child object. If you have multiple belongs_to links to another object you can use the syntax "ClassName.HasOneName" to specify which foreign has_one key on the other object to use. Note that you cannot have a has_one and belongs_to relationship with the same name.
`public static array` | $has_many | # This defines a one-to-many relationship. It is a map of component name to the remote data class. This defines a one-to-many relationship. It is a map of component name to the remote data class. This relationship type does not actually create a data structure itself - you need to define a matching $has_one relationship on the child class. Also, if the $has_one relationship on the child class has multiple links to this class you can use the syntax "ClassName.HasOneRelationshipName" in the remote data class definition to show which foreign key to use.
`public static array` | $many_many | # many-many relationship definitions. This is a map from component name to data type. many-many relationship definitions. This is a map from component name to data type.
`public static array` | $many_many_extraFields | # Extra fields to include on the connecting many-many table. This is a map from field name to field type. Extra fields to include on the connecting many-many table. This is a map from field name to field type. Example code:
    public static $many_many_extraFields = array(
            'Members' => array(
                    'Role' => 'Varchar(100)'
            )
    );
`public static array` | $belongs_many_many | # The inverse side of a many-many relationship. This is a map from component name to data type. The inverse side of a many-many relationship. This is a map from component name to data type.
`public static string` | $default_sort | # The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided. The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided.
`public static mixed` | $searchable_fields | # Default list of fields that can be scaffolded by the ModelAdmin search interface. Default list of fields that can be scaffolded by the ModelAdmin search interface. Overriding the default filter, with a custom defined filter:
           static $searchable_fields = array(
              "Name" => "PartialMatchFilter"
    );
Overriding the default form fields, with a custom defined field. The 'filter' parameter will be generated from `DBField::$default_search_filter_class`. The 'title' parameter will be generated from DataObject->fieldLabels().
           static $searchable_fields = array(
              "Name" => array(
                           "field" => "TextField"
                   )
    );
Overriding the default form field, filter and title:
           static $searchable_fields = array(
              "Organisation.ZipCode" => array(
                           "field" => "TextField",
                           "filter" => "PartialMatchFilter",
                           "title" => 'Organisation ZIP'
                   )
    );
`public static mixed` | $field_labels | # User defined labels for searchable_fields, used to override default display in the search form. User defined labels for searchable_fields, used to override default display in the search form. #### Used by ``DataObject::fieldLabels()``
`public static mixed` | $summary_fields | # Provides a default list of fields to be used by a 'summary' view of this object. Provides a default list of fields to be used by a 'summary' view of this object.
`public static mixed` | $allowed_actions | # Provides a list of allowed methods that can be called via RESTful api. Provides a list of allowed methods that can be called via RESTful api.

### Properties inherited from ViewableData

`$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -