Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
RedBeanModel Class Reference
Inheritance diagram for RedBeanModel:
BeanModel ObservableComponent A ActiveLanguage AuditEvent BaseCustomField BaseStarredModel ContactState Currency CustomFieldData CustomFieldsModel CustomFieldValue DateDateTime DDD DerivedAttributeMetadata E F FFF FileContent G GameNotification GGG GlobalMetadata H HHH III KanbanItem M MashableInboxForTestModel MessageSource MessageTranslation MixedRelationsModel NoBean OwnedModel P PerUserMetadata Portlet PP PPP PPPP ProjectAuditEvent QueryFromModel SavedCalendarSubscription ShortUrl StuckJob TestAttributeNamedLikeSqlKeywordModel TestBlobModel TestBooleanAttributeModel TestDatabaseBulkInsertModel TestDataUtilModel TestDateTimeModel TestDateTimeUserModel TestDefaultedAttributeModel TestGetAttributeLabelModel TestIdentityModel TestInvalidSpecificLinkType TestManyManyRelationToItemModel TestModelJoinHasManyAndHasOneBelongsToSide TestModelJoinHasManySide TestModelJoinHasOneSide TestModelJoinManyManySide TestModelJoinManyManySideTwo TestModelToMessagesModel TestNameModel TestOperatorTypeModel TestPolyOneToManyOneSide TestPolyOneToManyOneSideTwo TestPolyOneToManyPolySide TestPolyOneToManyPolySideOwned TestPrecisionModel TestReadOnlyAttributeModel TestSelfRelatingModel TestSimplestManyRelationModel TestSimplestModel TestTypesModel TestViewMetadataValidatorModel ThingWithCalculatedDates X Z ZZ

Public Member Functions

 getIsNewModel ()
 
 __construct ($setDefaults=true, RedBean_OODBBean $bean=null, $forceTreatAsCreation=false, $runConstruction=true)
 
 serialize ()
 
 unserialize ($data)
 
 getPrimaryBean ()
 
 getClassId ($modelClassName)
 
 getClassBean ($modelClassName)
 
 getModelIdentifier ()
 
 castDown (array $derivedModelClassNames)
 
 isSame (RedBeanModel $model)
 
 __toString ()
 
 __get ($attributeName)
 
 __set ($attributeName, $value)
 
 __isset ($attributeName)
 
 __unset ($attributeName)
 
 attributeNames ()
 
 isAttribute ($attributeName)
 
 isAttributeWithLowerCaseConversion ($attributeName)
 
 isAttributeReadOnly ($attributeName)
 
 isAttributeFormattedAsProbability ($attributeName)
 
 isAllowedToSetReadOnlyAttribute ($attributeName)
 
 rules ()
 
 behaviors ()
 
 attributeLabels ()
 
 abbreviatedAttributeLabels ()
 
 validate (array $attributeNames=null, $ignoreRequiredValidator=false)
 
 onBeforeValidate (CModelEvent $event)
 
 onAfterValidate ($event)
 
 getValidatorList ()
 
 getValidators ($attributeName=null)
 
 forgetValidators ()
 
 createValidators ()
 
 isUniqueAttributeValue ($attributeName, $value)
 
 save ($runValidation=true, array $attributeNames=null)
 
 isRelatedModelReallyModified ($relatedModel, $relationType, $isOwned)
 
 isReallyModified ($relationType, $isOwned)
 
 onBeforeSave ($event)
 
 onAfterSave ($event)
 
 onRedBeanOneToManyRelatedModelsChange ($event)
 
 onBeforeDelete ($event)
 
 onAfterDelete ($event)
 
 isModified ()
 
 delete ()
 
 isDeleted ()
 
 isDeletable ()
 
 forget ()
 
 isAttributeRequired ($attributeName)
 
 isAttributeSafe ($attributeName)
 
 getAttributeLabel ($attributeName)
 
 getAttributeLabelsForAllActiveLanguagesByAttributeName ($attributeName)
 
 hasErrors ($attributeNameOrNames=null)
 
 getErrors ($attributeNameOrNames=null)
 
 getError ($attributeName)
 
 addError ($attributeName, $errorMessage)
 
 addErrors (array $errors)
 
 clearErrors ($attributeName=null)
 
 generateAttributeLabel ($attributeName)
 
 getAttributes (array $attributeNames=null)
 
 setAttributes (array $values, $safeOnly=true)
 
 unsetAttributes ($attributeNames=null)
 
 onUnsafeAttribute ($name, $value)
 
 getScenario ()
 
 setScenario ($scenarioName)
 
 getSafeAttributeNames ()
 
 getIterator ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $item)
 
 offsetUnset ($offset)
 
 stringifyOneToManyRelatedModelsValues ($values)
 
 setIsCopied ()
 
 isCopied ()
 
 addValidator ($attribute, $validator, $params=array())
 
- Public Member Functions inherited from ObservableComponent
 init ()
 
 attachEvents ($events)
 
 events ()
 
 attachEventHandler ($name, $handler)
 
 detachEventHandler ($name, $handler)
 

Static Public Member Functions

static model ($className=null)
 
static getAll ($orderBy=null, $sortDescending=false, $modelClassName=null)
 
static getSubset (RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter=null, $offset=null, $count=null, $where=null, $orderBy=null, $modelClassName=null, $selectDistinct=false)
 
static getSubsetIds (RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter=null, $offset=null, $count=null, $where=null, $orderBy=null, $modelClassName=null, $selectDistinct=false)
 
static makeSubsetOrCountSqlQuery ($tableName, RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter, $offset=null, $count=null, $where=null, $orderBy=null, $selectCount=false, $selectDistinct=false, array $quotedExtraSelectColumnNameAndAliases=array())
 
static getCount (RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter=null, $where=null, $modelClassName=null, $selectDistinct=false)
 
static getById ($id, $modelClassName=null)
 
static deleteAll ()
 
static mangleTableName ()
 
static getTableName ()
 
static getTableNames ($classNames)
 
static getForeignKeyName ($modelClassName, $relationName)
 
static getModelClassNameByIdentifier ($identifier)
 
static getMetadata ()
 
static canSaveMetadata ()
 
static setMetadata (array $metadata)
 
static getDefaultMetadata ()
 
static isTypeDeletable ()
 
static forgetAll ()
 
static getModelLabelByTypeAndLanguage ($type, $language=null)
 
static getAnAttributeLabel ($attributeName)
 
static makeModel (RedBean_OODBBean $bean, $modelClassName=null)
 
static makeModels (array $beans, $modelClassName=null)
 
static getModuleClassName ()
 
static getLastClassInBeanHeirarchy ()
 
static getSortAttributesByAttribute ($attribute)
 
static isCacheable ()
 
static getYiiValidatorsToRedBeanValidators ()
 
static getHasManyOpposingRelationName (RedBeanModel $model, $precedingModelClassName, $precedingRelation)
 
static relationLinksToPrecedingRelation ($modelClassName, $relation, $precedingModelClassName=null, $precedingRelation=null)
 
static allowMemcacheCache ()
 
- Static Public Member Functions inherited from BeanModel
static getCanHaveBean ()
 
static getMetadata ()
 
static isAnAttribute ($attributeName)
 
static resolveAttributeModelClassName ($attributeName)
 
static getAttributeModelClassName ($attributeName)
 
static isRelation ($attributeName)
 
static isOwnedRelation ($attributeName)
 
static getRelationType ($relationName)
 
static getRelationModelClassName ($relationName)
 
static getRelationLinkType ($relationName)
 
static getRelationLinkName ($relationName)
 
static isRelationTypeAHasManyVariant ($relationName)
 
static isRelationTypeAHasOneVariant ($relationName)
 
static isADerivedRelationViaCastedUpModel ($relationName)
 
static getDerivedRelationType ($relationName)
 
static getDerivedRelationModelClassName ($relationName)
 
static getDerivedRelationViaCastedUpModelOpposingRelationName ($relationName)
 
static getInferredRelationModelClassNamesForRelation ($relation)
 
static getColumnNameByAttribute ($attributeName)
 
static getAttributeNames ()
 
static generateAnAttributeLabel ($attributeName)
 
static getAbbreviatedAttributeLabel ($attributeName)
 
static getTranslatedAttributeLabels ($language)
 
static getMixedInModelClassNames ()
 
static isRelationTypeAManyManyVariant ($relationName)
 

Data Fields

const MODEL_IDENTIFIER_DELIMITER = '_'
 
- Data Fields inherited from BeanModel
const HAS_ONE_BELONGS_TO = 0
 
const HAS_MANY_BELONGS_TO = 1
 
const HAS_ONE = 2
 
const HAS_MANY = 3
 
const MANY_MANY = 4
 
const OWNED = true
 
const NOT_OWNED = false
 
const CACHE_IDENTIFIER = 'BeanModelMapping'
 
const LINK_TYPE_ASSUMPTIVE = 0
 
const LINK_TYPE_SPECIFIC = 1
 
const LINK_TYPE_POLYMORPHIC = 2
 

Protected Member Functions

 constructDerived ($bean, $setDefaults)
 
 constructIncomplete ($bean)
 
 setNotModified ()
 
 onCreated ()
 
 onLoaded ()
 
 onModified ()
 
 mapAndCacheMetadataAndSetHints ($modelClassName, RedBean_OODBBean $bean)
 
 runDefaultValidators ()
 
 setClassBean ($modelClassName, RedBean_OODBBean $bean)
 
 unrestrictedGet ($attributeName)
 
 unrestrictedSet ($attributeName, $value)
 
 beforeValidate ()
 
 afterValidate ()
 
 beforeSave ()
 
 afterSave ()
 
 linkBeans ()
 
 beforeDelete ()
 
 afterDelete ()
 
 unrestrictedDelete ()
 
 deleteOwnedRelatedModels ($modelClassName)
 
 deleteForeignRelatedModels ($modelClassName)
 
 deleteManyManyRelations ($modelClassName)
 

Static Protected Member Functions

static makeCasedLinkName ($relationType, $linkType, $relationLinkName)
 
static getModelIdentifierByClassNameAndBeanId ($modelClassName, $beanId)
 
static assertMetadataIsValid (array $metadata)
 
static getByRelatedClassId ($relatedModelClassName, $id, $modelClassName=null)
 
static getLabel ($language=null)
 
static getPluralLabel ($language=null)
 
static getAttributeLabelByLanguage ($attributeName, $language)
 
static getTranslatedCustomAttributeLabelByLanguage ($attributeName, $languageCode)
 
static resolveModelClassNameForClassesWithoutBeans (&$modelClassName)
 
- Static Protected Member Functions inherited from BeanModel
static translatedAbbreviatedAttributeLabels ($language)
 
static translatedAttributeLabels ($language)
 
static getAttributeNamesToClassNamesForModel ()
 
static getAttributeNamesNotBelongsToOrManyManyForModel ()
 
static getRelationNameToRelationTypeModelClassNameAndOwnsForModel ()
 
static getDerivedRelationNameToTypeModelClassNameAndOppposingRelationForModel ()
 
static forgetBeanModel ($modelClassName)
 
static forgetAllBeanModels ()
 
static resolveCacheAndMapMetadataForAllClassesInHeirarchy ()
 
static resolveCachedMetadataForIntegrity ($cachedData)
 
static resolveLinkTypeAndRelationLinkName ($relationTypeModelClassNameAndOwns, &$linkType, &$relationLinkName)
 

Protected Attributes

 $modelClassNameToBean = array()
 
 $attributeNameToBeanAndClassName = array()
 
 $relationNameToRelatedModel = array()
 
 $unlinkedRelationNames = array()
 
 $unlinkedOwnedRelatedModelsToRemove = array()
 
 $validators = array()
 
 $attributeNameToErrors = array()
 
 $scenarioName = ''
 
 $modified = false
 
 $deleted = false
 
 $isInIsModified = false
 
 $isInHasErrors = false
 
 $isInGetErrors = false
 
 $isValidating = false
 
 $isSaving = false
 
 $isDeleting = false
 
 $isNewModel = false
 
 $isCopied = false
 
 $isSavableFromRelation = true
 

Static Protected Attributes

static $lastClassInBeanHeirarchy = 'RedBeanModel'
 
static $attributeLabelsByLanguage = array()
 
- Static Protected Attributes inherited from BeanModel
static $lastClassInBeanHeirarchy = 'BeanModel'
 

Detailed Description

Abstraction over the top of an application database accessed via RedBean. The base class for an MVC model. Replaces the M part of MVC in Yii. Yii maps from the database scheme to the objects, (good for database guys, not so good for OO guys), this maps from objects to the database schema.

A domain model is created by extending RedBeanModel and supplying a getDefaultMetadata() method.

Static getXxxx() methods can be supplied to query for the given domain models, and instance methods should supply additional behaviour.

getDefaultMetadata() returns an array of the class name mapped to an array containing 'members' mapped to an array of member names, (to be accessed as $model->memberName).

It can then optionally have, 'relations' mapped to an array of relation names, (to be accessed as $model->relationName), mapped to its type, (the extending model class to which it relates).

And it can then optionally have as well, 'rules' mapped to an array of attribute names, (attributes are members and relations), a validator name, and the parameters to the validator, if any, as per the Yii::CModel::rules() method.See http://www.yiiframework.com/wiki/56/reference-model-rules-validation.

These are used to automatically and dynamically create the database schema on the fly as opposed to Yii's getting attributes from an already existing schema.

Definition at line 67 of file RedBeanModel.php.

Constructor & Destructor Documentation

__construct (   $setDefaults = true,
RedBean_OODBBean  $bean = null,
  $forceTreatAsCreation = false,
  $runConstruction = true 
)

Constructs a new model. Important: Models are only constructed with beans by the RedBeanModel. Beans are never used by the application directly. The application can construct a new model object by constructing a model without specifying a bean. In other words, if Php had overloading a constructor with $setDefaults would be public, and a constructor taking a $bean and $forceTreatAsCreation would be private.

Parameters
$setDefaults.If false the default validators will not be run on construction. The Yii way is that defaults are filled in after the fact, which is counter the usual for objects.
$beanA bean. Never specified by an application.
$forceTreatAsCreation.Never specified by an application.
$runConstruction.Sometimes a model is needed to hook in events and the construction logic does not necessarily need to be run.
See Also
getById()
makeModel()
makeModels()

Definition at line 416 of file RedBeanModel.php.

Member Function Documentation

static model (   $className = null)
static

Returns the static model of the specified AR class. The model returned is a static instance of the AR class. It is provided for invoking class-level methods (something similar to static class methods.)

EVERY derived AR class must override this method as follows,

public static function model($className=__CLASS__)
{
    return parent::model($className);
}

This method will make a model that does not run construction

Parameters
string$classNameactive record class name.
Returns
CActiveRecord active record model instance.

Definition at line 181 of file RedBeanModel.php.

static getAll (   $orderBy = null,
  $sortDescending = false,
  $modelClassName = null 
)
static

Gets all the models from the database of the named model type.

Parameters
$orderByTODO
$modelClassNamePass only when getting it at runtime gets the wrong name.
Returns
An array of models of the type of the extending model.

Definition at line 205 of file RedBeanModel.php.

static getSubset ( RedBeanModelJoinTablesQueryAdapter  $joinTablesAdapter = null,
  $offset = null,
  $count = null,
  $where = null,
  $orderBy = null,
  $modelClassName = null,
  $selectDistinct = false 
)
static

Gets a range of models from the database of the named model type.

Parameters
$modelClassName
$joinTablesAdapternull or instance of joinTablesAdapter.
$offsetThe zero based index of the first model to be returned.
$countThe number of models to be returned.
$where
$orderBy- sql string. Example 'a desc' or 'a.b desc'. Currently only supports non-related attributes
$modelClassNamePass only when getting it at runtime gets the wrong name.
Returns
An array of models of the type of the extending model.

Definition at line 234 of file RedBeanModel.php.

static getSubsetIds ( RedBeanModelJoinTablesQueryAdapter  $joinTablesAdapter = null,
  $offset = null,
  $count = null,
  $where = null,
  $orderBy = null,
  $modelClassName = null,
  $selectDistinct = false 
)
static

Gets a range of model ids from the database of the named model type.

Parameters
$modelClassName
$joinTablesAdapternull or instance of joinTablesAdapter.
$offsetThe zero based index of the first model to be returned.
$countThe number of models to be returned.
$where
$orderBy- sql string. Example 'a desc' or 'a.b desc'. Currently only supports non-related attributes
$modelClassNamePass only when getting it at runtime gets the wrong name.
Returns
An array of models ids

Definition at line 268 of file RedBeanModel.php.

static makeSubsetOrCountSqlQuery (   $tableName,
RedBeanModelJoinTablesQueryAdapter  $joinTablesAdapter,
  $offset = null,
  $count = null,
  $where = null,
  $orderBy = null,
  $selectCount = false,
  $selectDistinct = false,
array  $quotedExtraSelectColumnNameAndAliases = array() 
)
static
Parameters
boolean$selectCountIf true then make this a count query. If false, select ids from rows.
array$quotedExtraSelectColumnNameAndAliases- extra columns to select.
Returns
string - sql statement.

Definition at line 300 of file RedBeanModel.php.

static getCount ( RedBeanModelJoinTablesQueryAdapter  $joinTablesAdapter = null,
  $where = null,
  $modelClassName = null,
  $selectDistinct = false 
)
static
Parameters
$modelClassName
$joinTablesAdapternull or instance of joinTablesAdapter.
$modelClassNamePass only when getting it at runtime gets the wrong name.

Definition at line 337 of file RedBeanModel.php.

static getById (   $id,
  $modelClassName = null 
)
static

Gets a model from the database by Id.

Parameters
$idInteger Id.
$modelClassNamePass only when getting it at runtime gets the wrong name.
Returns
A model of the type of the extending model.

Definition at line 368 of file RedBeanModel.php.

static deleteAll ( )
static

Delete all models

Definition at line 497 of file RedBeanModel.php.

constructIncomplete (   $bean)
protected

Utilized when pieces of information need to be constructed on an existing model, that can potentially be missing. For example, if a model is created, then a custom field is added, it is possible the cached model is missing the custom field customFieldData.

Parameters
unknown_type$bean

Definition at line 529 of file RedBeanModel.php.

setNotModified ( )
protected

Overriding constructors must call this function to ensure that they leave the newly constructed instance not modified since anything modifying the class during constructionm will set it modified automatically.

Definition at line 586 of file RedBeanModel.php.

static mangleTableName ( )
static

By default the table name is the lowercased class name. If this conflicts with a database keyword override to return true. RedBean does not quote table names in most cases.

Definition at line 598 of file RedBeanModel.php.

static getTableName ( )
static

Returns the table name for a class. For use by RedBeanModelDataProvider. It will not be of any use to an application. Applications should not be doing anything table related. Derived classes can refer directly to the table name.

Definition at line 611 of file RedBeanModel.php.

static getTableNames (   $classNames)
static

Returns the table names for an array of classes. For use by RedBeanModelDataProvider. It will not be of any use to an application.

Definition at line 629 of file RedBeanModel.php.

static getForeignKeyName (   $modelClassName,
  $relationName 
)
static

Used by classes such as containers which use sql to optimize getting models from the database.

Definition at line 643 of file RedBeanModel.php.

onCreated ( )
protected

Called on construction when a new model is created.

Definition at line 683 of file RedBeanModel.php.

onLoaded ( )
protected

Called on construction when a model is loaded.

Definition at line 695 of file RedBeanModel.php.

onModified ( )
protected

Called when a model is modified.

Definition at line 707 of file RedBeanModel.php.

mapAndCacheMetadataAndSetHints (   $modelClassName,
RedBean_OODBBean  $bean 
)
protected

Used for mixins.

$this->relationNameToRelationTypeModelClassNameAndOwns[$relationName] = array($relationType, $relationModelClassName, $owns, $linkType, $relationLinkName);

Definition at line 726 of file RedBeanModel.php.

runDefaultValidators ( )
protected

Used for mixins.

Definition at line 922 of file RedBeanModel.php.

getPrimaryBean ( )

For use only by RedBeanModel and RedBeanModels. Beans are never used by the application directly.

Definition at line 937 of file RedBeanModel.php.

getClassId (   $modelClassName)

Used for optimization.

Definition at line 945 of file RedBeanModel.php.

setClassBean (   $modelClassName,
RedBean_OODBBean  $bean 
)
protected

Used for mixins.

Definition at line 963 of file RedBeanModel.php.

static getMetadata ( )
static

Returns metadata for the model. Attempts to cache metadata, if it is not already cached.

See Also
getDefaultMetadata()
Returns
An array of metadata.

Definition at line 996 of file RedBeanModel.php.

static canSaveMetadata ( )
static

By default models cannot save their metadata, allowing them to be loaded quickly because the loading of of metadata can be avoided as much as possible. To make a model able to save its metadata override this method to return true. PUT it before the getDefaultMetadata in the derived class.

Definition at line 1053 of file RedBeanModel.php.

static setMetadata ( array  $metadata)
static

Sets metadata for the model.

See Also
getDefaultMetadata()
Returns
An array of metadata.

Definition at line 1063 of file RedBeanModel.php.

static getDefaultMetadata ( )
static

Returns the default meta data for the class. It must be appended to the meta data from the parent model, if any.

Definition at line 1107 of file RedBeanModel.php.

castDown ( array  $derivedModelClassNames)

Downcasting in general is a bad concept, but when pulling a Person from the database it would require a lot of jumping through hoops to make the RedBeanModel automatically figure out if that person is really a User, Contact, Customer or whatever might be derived from Person. So to avoid that complication and performance hit where it is not necessary this method can be used to convert a model to one of a given set of derivatives. If model is not one of those NotFoundException is thrown.

Definition at line 1170 of file RedBeanModel.php.

isSame ( RedBeanModel  $model)

Returns whether the given object is of the same type with the same id.

Definition at line 1236 of file RedBeanModel.php.

__toString ( )

Returns the displayable string for the class. Should be overridden in any model that can provide a meaningful string representation of itself.

Returns
A string.

Definition at line 1262 of file RedBeanModel.php.

__get (   $attributeName)

Exposes the members and relations of the model as if they were actual attributes of the model. See __set().

Parameters
$attributeNameA non-empty string that is the name of a member or relation.
See Also
attributeNames()
Returns
A value or model of the type specified as valid for the member or relation by the meta data supplied by the extending class's getMetadata() method.

Definition at line 1277 of file RedBeanModel.php.

unrestrictedGet (   $attributeName)
protected

A protected version of __get() for models to talk to themselves to use their dynamically created members from 'members' and 'relations' in its metadata.

Definition at line 1287 of file RedBeanModel.php.

__set (   $attributeName,
  $value 
)

Sets the members and relations of the model as if they were actual attributes of the model. For example, if Account extends RedBeanModel and its attributeNames() returns that one it has a member 'name' and a relation 'owner' they are simply accessed as:

$account = new Account();
$account->name = 'International Corp';
$account->owner = User::getByUsername('bill');
$account->save();
Parameters
$attributeNameA non-empty string that is the name of a member or relation of the model.
$valueA value or model of the type specified as valid for the member or relation by the meta data supplied by the extending class's getMetadata() method.

Definition at line 1426 of file RedBeanModel.php.

unrestrictedSet (   $attributeName,
  $value 
)
protected

A protected version of __set() for models to talk to themselves to use their dynamically created members from 'members' and 'relations' in its metadata.

Definition at line 1450 of file RedBeanModel.php.

__isset (   $attributeName)

Allows testing of the members and relations of the model as if they were actual attributes of the model.

Definition at line 1547 of file RedBeanModel.php.

__unset (   $attributeName)

Allows unsetting of the members and relations of the model as if they were actual attributes of the model.

Definition at line 1561 of file RedBeanModel.php.

attributeNames ( )

Returns the member and relation names defined by the extending class's getMetadata() method.

Definition at line 1572 of file RedBeanModel.php.

isAttribute (   $attributeName)

Returns true if the named attribute is one of the member or relation names defined by the extending class's getMetadata() method.

Definition at line 1582 of file RedBeanModel.php.

isAttributeWithLowerCaseConversion (   $attributeName)

Check if attribute name exist, but ignore case sensitivity This is used by designer to make difference for example between firstValue and firstvalue, because regular isAttribute methoed doesn't make difference. In most case you would want to use isAttribute method.

Parameters
string$attributeName
Returns
bool

Definition at line 1595 of file RedBeanModel.php.

isAttributeReadOnly (   $attributeName)

Returns true if the attribute is read-only.

Definition at line 1608 of file RedBeanModel.php.

isAttributeFormattedAsProbability (   $attributeName)

Returns true if the attribute is formattted as probability

Definition at line 1627 of file RedBeanModel.php.

isAllowedToSetReadOnlyAttribute (   $attributeName)
Parameters
boolean$attributeName
Returns
true/false whether the attributeName specified, it is allowed to be set externally even though it is a read-only attribute.

Definition at line 1648 of file RedBeanModel.php.

rules ( )

See the yii documentation. Not used by RedBeanModel.

See Also
getMetadata()

Definition at line 1657 of file RedBeanModel.php.

behaviors ( )

See the yii documentation.

Definition at line 1665 of file RedBeanModel.php.

attributeLabels ( )

See the yii documentation. RedBeanModels utilize translatedAttributeLabels to store any attribute information.

Definition at line 1674 of file RedBeanModel.php.

abbreviatedAttributeLabels ( )

Public method

Definition at line 1682 of file RedBeanModel.php.

validate ( array  $attributeNames = null,
  $ignoreRequiredValidator = false 
)

Performs validation using the validators specified in the 'rules' meta data by the extending class's getMetadata() method. Validation occurs on a new model or a modified model, but only proceeds to modified related models. Once validated a model will pass validation without revalidating until it is modified. Related models are only validated if the model validates. Cyclic relationships are prevented from causing problems by the validation either stopping at a non-validating model and only proceeding to non-validated models.

See Also
RedBeanModel
Parameters
$ignoreRequiredValidator- set to true in scenarios where you want to validate everything but the the required validator. An example is a search form.

Definition at line 1701 of file RedBeanModel.php.

beforeValidate ( )
protected

See the yii documentation.

Definition at line 1773 of file RedBeanModel.php.

afterValidate ( )
protected

See the yii documentation.

Definition at line 1783 of file RedBeanModel.php.

onBeforeValidate ( CModelEvent  $event)

See the yii documentation.

Definition at line 1791 of file RedBeanModel.php.

onAfterValidate (   $event)

See the yii documentation.

Definition at line 1799 of file RedBeanModel.php.

getValidatorList ( )

See the yii documentation.

Definition at line 1807 of file RedBeanModel.php.

getValidators (   $attributeName = null)

See the yii documentation.

Definition at line 1815 of file RedBeanModel.php.

forgetValidators ( )

Method to call to clear out validators from memory. Can help with performance. Used by async export for example.

Definition at line 1837 of file RedBeanModel.php.

createValidators ( )

See the yii documentation.

Definition at line 1848 of file RedBeanModel.php.

isUniqueAttributeValue (   $attributeName,
  $value 
)

Returns true if the attribute value does not already exist in the database. This is used in the unique validator, but on saving RedBean can still throw because the unique constraint on the column has been violated because it was concurrently updated between the Yii validator being called and the save actually occuring.

Definition at line 1860 of file RedBeanModel.php.

save (   $runValidation = true,
array  $attributeNames = null 
)

Saves the model to the database. Models are only saved if they have been modified and related models are saved before this model. If a related model is modified and needs saving the deems the model to be modified and need saving, which ensures that keys are updated. Cyclic relationships are prevented from causing problems by the save only proceeding to non-saved models.

Definition at line 1894 of file RedBeanModel.php.

isRelatedModelReallyModified (   $relatedModel,
  $relationType,
  $isOwned 
)

See Stories #82063952 and #82699138

See Also
isReallyModified
Parameters
$relatedModel
$relationTypeinteger
$isOwnedboolean
Returns
bool

Definition at line 2058 of file RedBeanModel.php.

isReallyModified (   $relationType,
  $isOwned 
)

See Stories #82063952 and #82699138 Overridden in OwnedSecurableItem. This means the fix is scoped down to just classes that extend OwnedSecurableItem, but the bug with isModified only manifests when there are default values on related models, which has only occurred on subClasses of OwnedSecurableItem.

This fix is probably temporarily until the way isModified() and save() methods work in RedBeanModel is refactored. This would be a large refactoring.

Parameters
$relationTypeinteger
$isOwnedboolean
Returns
bool

Definition at line 2084 of file RedBeanModel.php.

beforeSave ( )
protected

This method is invoked before saving a record (after validation, if any). The default implementation raises the onBeforeSave event. You may override this method to do any preparation work for record saving. Use isNewModel to determine whether the saving is for inserting or updating record. Make sure you call the parent implementation so that the event is raised properly.

Returns
boolean whether the saving should be executed. Defaults to true.

Definition at line 2100 of file RedBeanModel.php.

onBeforeSave (   $event)

This event is raised before the record is saved. By setting CModelEvent::isValid to be false, the normal save() process will be stopped.

Parameters
CModelEvent$eventthe event parameter
Since
1.0.2

Definition at line 2126 of file RedBeanModel.php.

onAfterSave (   $event)

This event is raised after the record is saved.

Parameters
CEvent$eventthe event parameter
Since
1.0.2

Definition at line 2136 of file RedBeanModel.php.

onRedBeanOneToManyRelatedModelsChange (   $event)

This event is raised on a RedBeanOneToManyRelatedModels change

Parameters
$event

Definition at line 2145 of file RedBeanModel.php.

onBeforeDelete (   $event)

This event is raised before the record is deleted. By setting CModelEvent::isValid to be false, the normal delete() process will be stopped.

Parameters
CModelEvent$eventthe event parameter
Since
1.0.2

Definition at line 2156 of file RedBeanModel.php.

onAfterDelete (   $event)

This event is raised after the record is deleted.

Parameters
CEvent$eventthe event parameter
Since
1.0.2

Definition at line 2166 of file RedBeanModel.php.

isModified ( )

Returns true if the model has been modified since it was saved or constructed.

Definition at line 2188 of file RedBeanModel.php.

delete ( )

Deletes the model from the database.

Definition at line 2232 of file RedBeanModel.php.

beforeDelete ( )
protected

This method is invoked before deleting a record. The default implementation raises the onBeforeDelete event. You may override this method to do any preparation work for record deletion. Make sure you call the parent implementation so that the event is raised properly.

Returns
boolean whether the record should be deleted. Defaults to true.

Definition at line 2268 of file RedBeanModel.php.

afterDelete ( )
protected

This method is invoked after deleting a record. The default implementation raises the onAfterDelete event. You may override this method to do postprocessing after the record is deleted. Make sure you call the parent implementation so that the event is raised properly.

Definition at line 2288 of file RedBeanModel.php.

static isTypeDeletable ( )
static

To be overriden on intermediate derived classes to return false so that deletes are not done on intermediate classes because the object relational mapping will not clean up properly. For example if User is a Person, and Person is a RedBeanModel delete should be called only on User, not on Person. So User must override isDeletable to return false.

Definition at line 2422 of file RedBeanModel.php.

isDeletable ( )

To be overridden by derived classes to prevent deletion.

Definition at line 2431 of file RedBeanModel.php.

static forgetAll ( )
static

Forgets about all of the objects so that when they are retrieved again they will be recreated from the database. For use in testing.

Definition at line 2440 of file RedBeanModel.php.

forget ( )

Forgets about the object so that if it is retrieved again it will be recreated from the database. For use in testing.

Definition at line 2452 of file RedBeanModel.php.

isAttributeRequired (   $attributeName)

See the yii documentation.

Definition at line 2462 of file RedBeanModel.php.

isAttributeSafe (   $attributeName)

See the yii documentation.

Definition at line 2478 of file RedBeanModel.php.

static getLabel (   $language = null)
staticprotected

Returns the display name for the model class. Defaults to the module label. Override if the model label is not the module label. Make sure to return a translated label. Also provides fall back in moduleClassName is null.

Parameters
null  |  string$language
Returns
dynamic label name based on module.

Definition at line 2512 of file RedBeanModel.php.

static getPluralLabel (   $language = null)
staticprotected

Returns the display name for plural of the model class. Defaults to the module label. Override if the model label is not the module label. Make sure to return a translated label

Parameters
null  |  string$language
Returns
dynamic label name based on module.

Definition at line 2527 of file RedBeanModel.php.

getAttributeLabel (   $attributeName)

See the yii documentation.

Definition at line 2539 of file RedBeanModel.php.

static getAnAttributeLabel (   $attributeName)
static

Static implementation of

See Also
getAttributeLabel

Definition at line 2547 of file RedBeanModel.php.

static getAttributeLabelByLanguage (   $attributeName,
  $language 
)
staticprotected

Given an attributeName and a language, retrieve the translated attribute label. Attempts to find a customized label in the metadata first, before falling back on the standard attribute label for the specified attribute.

Returns
string - translated attribute label

Definition at line 2557 of file RedBeanModel.php.

static getTranslatedCustomAttributeLabelByLanguage (   $attributeName,
  $languageCode 
)
staticprotected

Given an attributeName, attempt to find in the metadata a custom attribute label for the given language.

Returns
string - translated attribute label, if not found return null.

Definition at line 2589 of file RedBeanModel.php.

getAttributeLabelsForAllActiveLanguagesByAttributeName (   $attributeName)

Given an attributeName, return an array of all attribute labels for each active language.

Returns
array - attribute labels by language for the given attributeName.

Definition at line 2610 of file RedBeanModel.php.

hasErrors (   $attributeNameOrNames = null)

See the yii documentation. The yii hasErrors() takes an optional attribute name. RedBeanModel's hasErrors() takes an optional attribute name or array of attribute names. See getErrors() for an explanation of this difference.

Definition at line 2627 of file RedBeanModel.php.

getErrors (   $attributeNameOrNames = null)

See the yii documentation. The yii getErrors() takes an optional attribute name. RedBeanModel's getErrors() takes an optional attribute name or array of attribute names.

Parameters
@attributeNameOrNamesEither null, return all errors on the model and its related models, an attribute name on the model, return errors on that attribute, or an array of relation and attribute names, return errors on a related model's attribute.

Definition at line 2726 of file RedBeanModel.php.

getError (   $attributeName)

See the yii documentation.

Definition at line 2819 of file RedBeanModel.php.

addError (   $attributeName,
  $errorMessage 
)

See the yii documentation.

Definition at line 2828 of file RedBeanModel.php.

addErrors ( array  $errors)

See the yii documentation.

Definition at line 2841 of file RedBeanModel.php.

clearErrors (   $attributeName = null)

See the yii documentation.

Definition at line 2866 of file RedBeanModel.php.

generateAttributeLabel (   $attributeName)

See the yii documentation.

Definition at line 2882 of file RedBeanModel.php.

getAttributes ( array  $attributeNames = null)

See the yii documentation.

Definition at line 2891 of file RedBeanModel.php.

setAttributes ( array  $values,
  $safeOnly = true 
)

See the yii documentation.

Definition at line 2920 of file RedBeanModel.php.

unsetAttributes (   $attributeNames = null)

See the yii documentation.

Definition at line 2982 of file RedBeanModel.php.

onUnsafeAttribute (   $name,
  $value 
)

See the yii documentation.

Definition at line 2997 of file RedBeanModel.php.

getScenario ( )

See the yii documentation.

Definition at line 3009 of file RedBeanModel.php.

setScenario (   $scenarioName)

See the yii documentation.

Definition at line 3017 of file RedBeanModel.php.

getSafeAttributeNames ( )

See the yii documentation.

Definition at line 3026 of file RedBeanModel.php.

getIterator ( )

See the yii documentation.

Definition at line 3057 of file RedBeanModel.php.

offsetExists (   $offset)

See the yii documentation.

Definition at line 3065 of file RedBeanModel.php.

offsetGet (   $offset)

See the yii documentation.

Definition at line 3073 of file RedBeanModel.php.

offsetSet (   $offset,
  $item 
)

See the yii documentation.

Definition at line 3081 of file RedBeanModel.php.

offsetUnset (   $offset)

See the yii documentation.

Definition at line 3089 of file RedBeanModel.php.

static makeModel ( RedBean_OODBBean  $bean,
  $modelClassName = null 
)
static

Creates an instance of the extending model wrapping the given bean. For use only by models. Beans are never used by the application directly.

Parameters
$beanA RedBean bean.
$modelClassNamePass only when getting it at runtime gets the wrong name.
Returns
An instance of the type of the extending model.

Definition at line 3104 of file RedBeanModel.php.

static makeModels ( array  $beans,
  $modelClassName = null 
)
static

Creates an array of instances of the named model type wrapping the given beans. For use only by models. Beans are never used by the application directly.

Parameters
$beansAn array of RedBean beans.
$modelClassNamePass only when getting it at runtime gets the wrong name.
Returns
An array of instances of the type of the extending model.

Definition at line 3135 of file RedBeanModel.php.

stringifyOneToManyRelatedModelsValues (   $values)

Given an array of data, create stringified content.

Parameters
array$values

Definition at line 3165 of file RedBeanModel.php.

static resolveModelClassNameForClassesWithoutBeans ( $modelClassName)
staticprotected

Resolve and get model class name used for table retrieval factoring in when a class does not have a bean and must use a parent class

Parameters
string$modelClassName

Definition at line 3176 of file RedBeanModel.php.

static getSortAttributesByAttribute (   $attribute)
static

Returns a list of attributes to be added when sorting by the attribute

Parameters
string$attribute
Returns
array

Definition at line 3202 of file RedBeanModel.php.

setIsCopied ( )

Utilized by copy mechanism, helps elements, views, understand the model better before the new model is saved.

Definition at line 3210 of file RedBeanModel.php.

isCopied ( )
Returns
bool

Definition at line 3218 of file RedBeanModel.php.

static isCacheable ( )
static
Returns
bool

Definition at line 3226 of file RedBeanModel.php.

addValidator (   $attribute,
  $validator,
  $params = array() 
)

Wrapper for CValidator::createValidator

Parameters
$attribute
$validator
array$params

Definition at line 3242 of file RedBeanModel.php.

static relationLinksToPrecedingRelation (   $modelClassName,
  $relation,
  $precedingModelClassName = null,
  $precedingRelation = null 
)
static
Parameters
string$modelClassName
string$relation
null | string$precedingModelClassName
null | string$precedingRelation
Returns
bool

Definition at line 3274 of file RedBeanModel.php.

static allowMemcacheCache ( )
static

Whether or not this model instances should be cached in memcache

Returns
bool

Definition at line 3315 of file RedBeanModel.php.

Field Documentation

const MODEL_IDENTIFIER_DELIMITER = '_'

Character used as delimiter when generating model identifiers

Definition at line 72 of file RedBeanModel.php.


The documentation for this class was generated from the following file:
Generated on Fri Sep 25 2020 07:10:57
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.