class Doctrine_File_Index extends Doctrine_Record (View source)

Doctrine_File_Index

Constants

STATE_DIRTY

DIRTY STATE a Doctrine_Record is in dirty state when its properties are changed

STATE_TDIRTY

TDIRTY STATE a Doctrine_Record is in transient dirty state when it is created and some of its fields are modified but it is NOT yet persisted into database

STATE_CLEAN

CLEAN STATE a Doctrine_Record is in clean state when all of its properties are loaded from the database and none of its properties are changed

STATE_PROXY

PROXY STATE a Doctrine_Record is in proxy state when its properties are not fully loaded

STATE_TCLEAN

NEW TCLEAN a Doctrine_Record is in transient clean state when it is created and none of its fields are modified

STATE_LOCKED

LOCKED STATE a Doctrine_Record is temporarily locked during deletes and saves

This state is used internally to ensure that circular deletes and saves will not cause infinite loops

STATE_TLOCKED

TLOCKED STATE a Doctrine_Record is temporarily locked (and transient) during deletes and saves

This state is used internally to ensure that circular deletes and saves will not cause infinite loops

Properties

protected Doctrine_Locator $_locator from Doctrine_Locator_Injectable
protected array $_resources from Doctrine_Locator_Injectable
static protected Doctrine_Null $_null from Doctrine_Locator_Injectable
protected $_table from Doctrine_Record_Abstract
protected Doctrine_Node_ $_node from Doctrine_Record
protected integer $_id from Doctrine_Record
protected array $_data each element is one of 3 following types: - simple type (int, string) - field has a scalar value - null - field has NULL value in DB - Doctrine_Null - field value is unknown, it wasn't loaded yet from Doctrine_Record
protected array $_values from Doctrine_Record
protected integer $_state from Doctrine_Record
protected array $_lastModified from Doctrine_Record
protected array $_modified from Doctrine_Record
protected array $_oldValues from Doctrine_Record
protected Doctrine_Validator_ErrorStack $_errorStack from Doctrine_Record
protected array $_references from Doctrine_Record
protected string $_pendingDeletes Doctrine_Collection of objects needing to be deleted on save from Doctrine_Record
$_pendingUnlinks Array of pending un links in format alias => keys to be executed after save from Doctrine_Record
static protected array $_customAccessors Array of custom accessors for cache from Doctrine_Record
static protected array $_customMutators Array of custom mutators for cache from Doctrine_Record
protected boolean $_serializeReferences Whether or not to serialize references when a Doctrine_Record is serialized from Doctrine_Record
protected array $_invokedSaveHooks Array containing the save hooks and events that have been invoked from Doctrine_Record

Methods

setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

getLocator()

getLocator returns the locator associated with this object

mixed
locate(string $name)

locate locates a resource by given name and returns it

bind($name, $resource)

bind binds a resource to a name

static void
initNullObject(Doctrine_Null $null)

initNullObject initializes the null object

static Doctrine_Null
getNullObject()

getNullObject returns the null object associated with this object

setArray(array $array)

Set an entire aray to the data

void
__set($name, $value)

Set key and value to data

mixed
__get(mixed $name)

Get key from data

boolean
__isset(string $name)

Check if key exists in data

void
__unset(string $name)

deletes a column or a related component.

boolean
offsetExists(mixed $offset)

Check if an offset axists

mixed
offsetGet(mixed $offset)

An alias of get()

void
offsetSet(mixed $offset, mixed $value)

Sets $offset to $value

offsetUnset(mixed $offset)

Unset a given offset

boolean
remove(mixed $offset)

Remove the element with the specified offset

mixed
get(mixed $fieldName, boolean $load = true)

returns a value of a property or a related component

set($fieldName, mixed $value, $load = true)

alters mapped values, properties and related components.

boolean
contains(string $fieldName)

test whether a field (column, mapped value, related component, accessor) is accessible by see get()

void
add(mixed $value)

Add the value

setTableDefinition()

No description

setUp()

setUp this method is used for setting up relations and attributes it should be implemented by child classes

getTable()

returns the table object for this record.

addListener($listener, $name = null)

addListener

mixed
index(string $name, array $definition = array())

index defines or retrieves an index if the second parameter is set this method defines an index if not this method retrieves index named $name

void
unique(array $fields, array $options = array(), bool $createUniqueIndex = true)

Defines a n-uple of fields that must be unique for every record.

setAttribute($attr, $value)

No description

setTableName($tableName)

No description

setInheritanceMap($map)

No description

setSubclasses($map)

No description

mixed
attribute(mixed $attr, mixed $value)

attribute sets or retrieves an option

mixed
option(mixed $name, mixed $value = null)

option sets or retrieves an option

hasOne()

Binds One-to-One aggregate relation

hasMany()

Binds One-to-Many / Many-to-Many aggregate relation

void
hasColumn(string $name, string $type = null, integer $length = null, mixed $options = array())

Sets a column definition

void
hasColumns(array $definitions)

Set multiple column definitions at once

void
setColumnOptions($name, array $options)

Customize the array of options for a column or multiple columns. First argument can be a single field/column name or an array of them. The second argument is an array of options.

void
setColumnOption(string $columnName, string $option, string $value)

Set an individual column option

bindQueryParts(array $queryParts)

bindQueryParts binds query parts to given component

actAs(mixed $tpl, array $options = array())

Loads the given plugin.

check(mixed $constraint, string $name = null)

Adds a check constraint.

__construct(Doctrine_Table|null $table = null, boolean $isNewEntry = false)

constructor

boolean
serializeReferences(boolean $bool = null)

Set whether or not to serialize references.

static integer
_index()

the current instance counter used to generate unique ids for php objects. Contains the next identifier.

void
construct()

construct Empty template method to provide concrete Record classes with the possibility to hook into the constructor procedure

integer
getOid()

No description

oid()

No description

invokeSaveHooks(string $when, string $type, Doctrine_Event $event = null)

calls a subclass hook. Idempotent until see clearInvokedSaveHooks() is called.

clearInvokedSaveHooks()

makes all the already used save hooks available again

boolean
isValid(boolean $deep = false, boolean $hooks = true)

tests validity of the record using the current data.

validate()

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure, doing any custom / specialized validations that are neccessary.

validateOnUpdate()

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure only when the record is going to be updated.

validateOnInsert()

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure only when the record is going to be inserted into the data store the first time.

preSerialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

postSerialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

preUnserialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

postUnserialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

preSave($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure.

postSave($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure.

preDelete($event)

Empty template method to provide concrete Record classes with the possibility to hook into the deletion procedure.

postDelete($event)

Empty template method to provide concrete Record classes with the possibility to hook into the deletion procedure.

preUpdate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be updated.

postUpdate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be updated.

preInsert($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be inserted into the data store the first time.

postInsert($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be inserted into the data store the first time.

preValidate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure. Useful for cleaning up data before validating it.

postValidate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure.

preDqlSelect($event)

Empty template method to provide Record classes with the ability to alter DQL select queries at runtime

preDqlUpdate($event)

Empty template method to provide Record classes with the ability to alter DQL update queries at runtime

preDqlDelete($event)

Empty template method to provide Record classes with the ability to alter DQL delete queries at runtime

preHydrate($event)

Empty template method to provide Record classes with the ability to alter hydration before it runs

postHydrate($event)

Empty template method to provide Record classes with the ability to alter hydration after it runs

string
getErrorStackAsString()

Get the record error stack as a human readable string.

getErrorStack()

retrieves the ErrorStack. To be called after a failed validation attempt (see isValid()).

errorStack(Doctrine_Validator_ErrorStack $stack = null)

assigns the ErrorStack or returns it if called without parameters

void
assignInheritanceValues()

Assign the inheritance column values

boolean
assignDefaultValues(boolean $overwrite = false)

setDefaultValues sets the default values for records internal data

array
cleanData(array $data)

cleanData leaves the $data array only with values whose key is a field inside this record and returns the values that were removed from $data. Also converts any values of 'null' to objects of type Doctrine_Null.

void
hydrate(array $data, boolean $overwriteLocalChanges = true)

hydrate hydrates this object from given array

string
serialize()

serialize this method is automatically called when an instance of Doctrine_Record is serialized

void
unserialize(string $serialized)

this method is automatically called everytime an instance is unserialized

null|integer
state(integer|string $state = null)

assigns the state of this record or returns it if called without parameters

boolean
refresh(bool $deep = false)

refresh refresh internal data from the database

refreshRelated(string $name = null)

refresh refresh data of related objects from the database

void
clearRelated(string $name = null)

Clear a related reference or all references

boolean
relatedExists(string $name)

Check if a related relationship exists. Will lazily load the relationship in order to check. If the reference didn't already exist and it doesn't exist in the database, the related reference will be cleared immediately.

array
getData()

return all the internal data (columns)

mixed
rawGet($fieldName)

returns the value of a property (column). If the property is not yet loaded this method does NOT load it.

boolean
load(array $data = array())

loads all the uninitialized properties from the database.

boolean
isInProxyState()

indicates whether record has any not loaded fields

boolean
hasAccessor(string $fieldName, string $accessor = null)

sets a fieldname to have a custom accessor or check if a field has a custom accessor defined (when called without $accessor parameter).

void
clearAccessor(string $fieldName)

clears the accessor for a field name

string
getAccessor(string $fieldName)

gets the custom accessor for a field name

array
getAccessors()

gets all accessors for this component instance

boolean
hasMutator(string $fieldName, string $mutator = null)

sets a fieldname to have a custom mutator or check if a field has a custom mutator defined (when called without the $mutator parameter)

string
getMutator($fieldName)

gets the custom mutator for a field name

void
clearMutator(string $fieldName)

clears the custom mutator for a field name

array
getMutators()

gets all custom mutators for this component instance

hasAccessorMutator($fieldName, $accessor, $mutator)

Set a fieldname to have a custom accessor and mutator

_get($fieldName, $load = true)

No description

void
mapValue(string $name, mixed $value = null)

sets a value that will be managed as if it were a field by magic accessor and mutators, see get() and see set().

boolean
hasMappedValue(string $name)

Tests whether a mapped value exists

_set($fieldName, $value, $load = true)

No description

boolean
_isValueModified(string $type, string $old, string $new)

Check if a value has changed according to Doctrine Doctrine is loose with type checking in the same ways PHP is for consistancy of behavior

coreSetRelated(string $name, Doctrine_Record|Doctrine_Collection $value)

Places a related component in the object graph.

array
getPendingDeletes()

returns Doctrine_Record instances which need to be deleted on save

array
getPendingUnlinks()

returns Doctrine_Record instances which need to be unlinked (deleting the relation) on save

void
resetPendingUnlinks()

resets pending record unlinks

void
save(Doctrine_Connection $conn = null)

applies the changes made to this object into database this method is smart enough to know if any changes are made and whether to use INSERT or UPDATE statement

TRUE
trySave(Doctrine_Connection $conn = null)

tries to save the object and all its related components.

integer
replace(Doctrine_Connection $conn = null)

executes a SQL REPLACE query. A REPLACE query is identical to a INSERT query, except that if there is already a row in the table with the same key field values, the REPLACE query just updates its values instead of inserting a new row.

array
getModified(boolean $old = false, boolean $last = false)

retrieves an array of modified fields and associated new values.

array
getLastModified(boolean $old = false)

returns an array of the modified fields from the last transaction.

array
getPrepared(array $array = array())

Retrieves data prepared for a sql transaction.

integer
count()

implements Countable interface

integer
columnCount()

alias for see count()

array
toArray(boolean $deep = true, boolean $prefixKey = false)

returns the record representation as an array

void
merge($data, $deep = true)

merges this record with an array of values or with another existing instance of this object

void
fromArray(array $array, bool $deep = true)

imports data from a php array

synchronizeWithArray(array $array, bool $deep = true)

synchronizes a Doctrine_Record instance and its relations with data from an array

string
exportTo(string $type, string $deep = true)

exports instance to a chosen format

void
importFrom($type, $data, $deep = true)

imports data from a chosen format in the current instance

boolean
exists()

returns true if this record is saved in the database, otherwise false (it is transient)

boolean
isModified(boolean $deep = false)

returns true if this record was modified, otherwise false

boolean
hasRelation(mixed $fieldName)

checks existence of properties and related components

getIterator()

implements IteratorAggregate interface

boolean
delete(Doctrine_Connection $conn = null)

deletes this data access object and all the related composites this operation is isolated by a transaction

copy(boolean $deep = false)

generates a copy of this object. Returns an instance of the same class of $this.

void
assignIdentifier(mixed $id = false)

assigns an identifier to the instance, for database storage

array
identifier()

returns the primary keys of this object

integer
getIncremented()

returns the value of autoincremented primary key of this object (if any)

getLast()

getLast this method is used internally by Doctrine_Query it is needed to provide compatibility between records and collections

boolean
hasReference(string $name)

tests whether a relation is set

reference(string $name)

gets a related component

obtainReference(string $name)

gets a related component and fails if it does not exist

array
getReferences()

get all related components

setRelated(string $alias, Doctrine_Access $coll)

set a related component

void
loadReference(string $name)

loadReference loads a related component

call($callback, $column)

call

getNode()

getter for node associated with this record

unshiftFilter(Doctrine_Record_Filter $filter)

No description

unlink(string $alias, array $ids = array(), boolean $now = false)

unlink removes links from this record to given records if no ids are given, it removes all links

unlinkInDb(string $alias, array $ids = array())

unlink now the related components, querying the db

link(string $alias, array $ids, boolean $now = false)

creates links from this record to given records

linkInDb(string $alias, array $ids)

creates links from this record to given records now, querying the db

void
_resetModified()

Reset the modified array and store the old array in lastModified so it can be accessed by users after saving a record, since the modified array is reset after the object is saved.

mixed
__call(string $method, array $args)

magic method used for method overloading

deleteNode()

used to delete node from tree - MUST BE USE TO DELETE RECORD IF TABLE ACTS AS TREE

free(boolean $deep = false)

Helps freeing the memory occupied by the entity.

string
toString()

__toString alias

string
__toString()

magic method

Details

Doctrine_Locator_Injectable setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

Parameters

Doctrine_Locator $locator the locator object

Return Value

Doctrine_Locator_Injectable this instance

Doctrine_Locator getLocator()

getLocator returns the locator associated with this object

if there are no locator locally associated then this method tries to fetch the current global locator

Return Value

Doctrine_Locator

mixed locate(string $name)

locate locates a resource by given name and returns it

if the resource cannot be found locally this method tries to use the global locator for finding the resource

Parameters

string $name the name of the resource

Return Value

mixed the located resource

Exceptions

Doctrine_Locator_Exception if the resource could not be found

See also

Doctrine_Locator::locate

Doctrine_Locator bind($name, $resource)

bind binds a resource to a name

Parameters

$name
$resource

Return Value

Doctrine_Locator this object

static void initNullObject(Doctrine_Null $null)

initNullObject initializes the null object

Parameters

Doctrine_Null $null

Return Value

void

static Doctrine_Null getNullObject()

getNullObject returns the null object associated with this object

Return Value

Doctrine_Null

Doctrine_Access setArray(array $array)

Set an entire aray to the data

Parameters

array $array An array of key => value pairs

Return Value

Doctrine_Access

void __set($name, $value)

Set key and value to data

Parameters

$name
$value

Return Value

void

See also

set, offsetSet

mixed __get(mixed $name)

Get key from data

Parameters

mixed $name

Return Value

mixed

See also

get, offsetGet

boolean __isset(string $name)

Check if key exists in data

Parameters

string $name

Return Value

boolean whether or not this object contains $name

void __unset(string $name)

deletes a column or a related component.

Parameters

string $name

Return Value

void

boolean offsetExists(mixed $offset)

Check if an offset axists

Parameters

mixed $offset

Return Value

boolean Whether or not this object contains $offset

mixed offsetGet(mixed $offset)

An alias of get()

Parameters

mixed $offset

Return Value

mixed

See also

get, __get

void offsetSet(mixed $offset, mixed $value)

Sets $offset to $value

Parameters

mixed $offset
mixed $value

Return Value

void

See also

set, __set

offsetUnset(mixed $offset)

Unset a given offset

Parameters

mixed $offset

See also

set, offsetSet, __set

boolean remove(mixed $offset)

Remove the element with the specified offset

Parameters

mixed $offset The offset to remove

Return Value

boolean True if removed otherwise false

mixed get(mixed $fieldName, boolean $load = true)

returns a value of a property or a related component

Parameters

mixed $fieldName name of the property or related component
boolean $load whether or not to invoke the loading procedure

Return Value

mixed

Exceptions

Doctrine_Record_Exception if trying to get a value of unknown property / related component

set($fieldName, mixed $value, $load = true)

alters mapped values, properties and related components.

Parameters

$fieldName
mixed $value The value to set the offset to
$load

Exceptions

Doctrine_Record_Exception if trying to set a value for unknown property / related component
Doctrine_Record_Exception if trying to set a value of wrong type for related component

boolean contains(string $fieldName)

test whether a field (column, mapped value, related component, accessor) is accessible by see get()

Parameters

string $fieldName

Return Value

boolean True if exists otherwise false

void add(mixed $value)

Add the value

Parameters

mixed $value The value to add

Return Value

void

setTableDefinition()

setUp()

setUp this method is used for setting up relations and attributes it should be implemented by child classes

Doctrine_Table getTable()

returns the table object for this record.

Return Value

Doctrine_Table the associated table object

Doctrine_Record addListener($listener, $name = null)

addListener

Parameters

$listener
$name

Return Value

Doctrine_Record

mixed index(string $name, array $definition = array())

index defines or retrieves an index if the second parameter is set this method defines an index if not this method retrieves index named $name

Parameters

string $name the name of the index
array $definition the definition array

Return Value

mixed

void unique(array $fields, array $options = array(), bool $createUniqueIndex = true)

Defines a n-uple of fields that must be unique for every record.

This method Will automatically add UNIQUE index definition and validate the values on save. The UNIQUE index is not created in the database until you use see export().

Parameters

array $fields values are fieldnames
array $options array of options for unique validator
bool $createUniqueIndex Whether or not to create a unique index in the database

Return Value

void

setAttribute($attr, $value)

Parameters

$attr
$value

setTableName($tableName)

Parameters

$tableName

setInheritanceMap($map)

Parameters

$map

setSubclasses($map)

Parameters

$map

mixed attribute(mixed $attr, mixed $value)

attribute sets or retrieves an option

Parameters

mixed $attr
mixed $value

Return Value

mixed

See also

Doctrine_Core::ATTR_* constants availible attributes

mixed option(mixed $name, mixed $value = null)

option sets or retrieves an option

Parameters

mixed $name the name of the option
mixed $value options value

Return Value

mixed

See also

Doctrine_Table::$options availible options

Doctrine_Record hasOne()

Binds One-to-One aggregate relation

Return Value

Doctrine_Record this object

See also

Doctrine_Relation::_$definition

Doctrine_Record hasMany()

Binds One-to-Many / Many-to-Many aggregate relation

Return Value

Doctrine_Record this object

See also

Doctrine_Relation::_$definition

void hasColumn(string $name, string $type = null, integer $length = null, mixed $options = array())

Sets a column definition

Parameters

string $name
string $type
integer $length
mixed $options

Return Value

void

void hasColumns(array $definitions)

Set multiple column definitions at once

Parameters

array $definitions

Return Value

void

void setColumnOptions($name, array $options)

Customize the array of options for a column or multiple columns. First argument can be a single field/column name or an array of them. The second argument is an array of options.

[php] public function setTableDefinition() { parent::setTableDefinition(); $this->setColumnOptions('username', array( 'unique' => true )); }

Parameters

$name
array $options

Return Value

void

void setColumnOption(string $columnName, string $option, string $value)

Set an individual column option

Parameters

string $columnName
string $option
string $value

Return Value

void

Doctrine_Record bindQueryParts(array $queryParts)

bindQueryParts binds query parts to given component

Parameters

array $queryParts an array of pre-bound query parts

Return Value

Doctrine_Record this object

loadGenerator(Doctrine_Record_Generator $generator)

Parameters

Doctrine_Record_Generator $generator

Doctrine_Record actAs(mixed $tpl, array $options = array())

Loads the given plugin.

This method loads a behavior in the record. It will add the behavior also to the record table if it. It is tipically called in see setUp().

Parameters

mixed $tpl if an object, must be a subclass of Doctrine_Template. If a string, Doctrine will try to instantiate an object of the classes Doctrine_Template_$tpl and subsequently $tpl, using also autoloading capabilities if defined.
array $options argument to pass to the template constructor if $tpl is a class name

Return Value

Doctrine_Record this object; provides a fluent interface.

Exceptions

Doctrine_Record_Exception if $tpl is neither an instance of Doctrine_Template subclass or a valid class name, that could be instantiated.

Doctrine_Record check(mixed $constraint, string $name = null)

Adds a check constraint.

This method will add a CHECK constraint to the record table.

Parameters

mixed $constraint either a SQL constraint portion or an array of CHECK constraints. If array, all values will be added as constraint
string $name optional constraint name. Not used if $constraint is an array.

Return Value

Doctrine_Record this object

__construct(Doctrine_Table|null $table = null, boolean $isNewEntry = false)

constructor

Parameters

Doctrine_Table|null $table a Doctrine_Table object or null, if null the table object is retrieved from current connection
boolean $isNewEntry whether or not this record is transient

Exceptions

Doctrine_Connection_Exception if object is created using the new operator and there are no open connections
Doctrine_Record_Exception if the cleanData operation fails somehow

boolean serializeReferences(boolean $bool = null)

Set whether or not to serialize references.

This is used by caching since we want to serialize references when caching but not when just normally serializing a instance

Parameters

boolean $bool

Return Value

boolean $bool

static integer _index()

the current instance counter used to generate unique ids for php objects. Contains the next identifier.

Return Value

integer

void construct()

construct Empty template method to provide concrete Record classes with the possibility to hook into the constructor procedure

Return Value

void

integer getOid()

Return Value

integer the object identifier

See also

$_oid;

Doctrine_Event invokeSaveHooks(string $when, string $type, Doctrine_Event $event = null)

calls a subclass hook. Idempotent until see clearInvokedSaveHooks() is called.

$this->invokeSaveHooks('pre', 'save');

Parameters

string $when 'post' or 'pre'
string $type serialize, unserialize, save, delete, update, insert, validate, dqlSelect, dqlDelete, hydrate
Doctrine_Event $event event raised

Return Value

Doctrine_Event the event generated using the type, if not specified

clearInvokedSaveHooks()

makes all the already used save hooks available again

boolean isValid(boolean $deep = false, boolean $hooks = true)

tests validity of the record using the current data.

Parameters

boolean $deep run the validation process on the relations
boolean $hooks invoke save hooks before start

Return Value

boolean whether or not this record is valid

protected validate()

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure, doing any custom / specialized validations that are neccessary.

protected validateOnUpdate()

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure only when the record is going to be updated.

protected validateOnInsert()

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure only when the record is going to be inserted into the data store the first time.

preSerialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

Parameters

$event

postSerialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

Parameters

$event

preUnserialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

Parameters

$event

postUnserialize($event)

Empty template method to provide concrete Record classes with the possibility to hook into the serializing procedure.

Parameters

$event

preSave($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure.

Parameters

$event

postSave($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure.

Parameters

$event

preDelete($event)

Empty template method to provide concrete Record classes with the possibility to hook into the deletion procedure.

Parameters

$event

postDelete($event)

Empty template method to provide concrete Record classes with the possibility to hook into the deletion procedure.

Parameters

$event

preUpdate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be updated.

Parameters

$event

postUpdate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be updated.

Parameters

$event

preInsert($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be inserted into the data store the first time.

Parameters

$event

postInsert($event)

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be inserted into the data store the first time.

Parameters

$event

preValidate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure. Useful for cleaning up data before validating it.

Parameters

$event

postValidate($event)

Empty template method to provide concrete Record classes with the possibility to hook into the validation procedure.

Parameters

$event

preDqlSelect($event)

Empty template method to provide Record classes with the ability to alter DQL select queries at runtime

Parameters

$event

preDqlUpdate($event)

Empty template method to provide Record classes with the ability to alter DQL update queries at runtime

Parameters

$event

preDqlDelete($event)

Empty template method to provide Record classes with the ability to alter DQL delete queries at runtime

Parameters

$event

preHydrate($event)

Empty template method to provide Record classes with the ability to alter hydration before it runs

Parameters

$event

postHydrate($event)

Empty template method to provide Record classes with the ability to alter hydration after it runs

Parameters

$event

string getErrorStackAsString()

Get the record error stack as a human readable string.

Useful for outputting errors to user via web browser

Return Value

string $message

Doctrine_Validator_ErrorStack getErrorStack()

retrieves the ErrorStack. To be called after a failed validation attempt (see isValid()).

Return Value

Doctrine_Validator_ErrorStack returns the errorStack associated with this record

void|Doctrine_Validator_ErrorStack errorStack(Doctrine_Validator_ErrorStack $stack = null)

assigns the ErrorStack or returns it if called without parameters

Parameters

Doctrine_Validator_ErrorStack $stack errorStack to be assigned for this record

Return Value

void|Doctrine_Validator_ErrorStack returns the errorStack associated with this record

void assignInheritanceValues()

Assign the inheritance column values

Return Value

void

boolean assignDefaultValues(boolean $overwrite = false)

setDefaultValues sets the default values for records internal data

Parameters

boolean $overwrite whether or not to overwrite the already set values

Return Value

boolean

array cleanData(array $data)

cleanData leaves the $data array only with values whose key is a field inside this record and returns the values that were removed from $data. Also converts any values of 'null' to objects of type Doctrine_Null.

Parameters

array $data data array to be cleaned

Return Value

array values cleaned from data

void hydrate(array $data, boolean $overwriteLocalChanges = true)

hydrate hydrates this object from given array

Parameters

array $data
boolean $overwriteLocalChanges whether to overwrite the unsaved (dirty) data

Return Value

void

string serialize()

serialize this method is automatically called when an instance of Doctrine_Record is serialized

Return Value

string

void unserialize(string $serialized)

this method is automatically called everytime an instance is unserialized

Parameters

string $serialized Doctrine_Record as serialized string

Return Value

void

Exceptions

Doctrine_Record_Exception if the cleanData operation fails somehow

null|integer state(integer|string $state = null)

assigns the state of this record or returns it if called without parameters

Parameters

integer|string $state if set, this method tries to set the record state to $state

Return Value

null|integer

Exceptions

Doctrine_Record_State_Exception if trying to set an unknown state

See also

Doctrine_Record::STATE_* constants

boolean refresh(bool $deep = false)

refresh refresh internal data from the database

Parameters

bool $deep If true, fetch also current relations. Caution: this deletes any aggregated values you may have queried beforee

Return Value

boolean

Exceptions

Doctrine_Record_Exception When the refresh operation fails (when the database row this record represents does not exist anymore)

Doctrine_Record refreshRelated(string $name = null)

refresh refresh data of related objects from the database

Parameters

string $name name of a related component. if set, this method only refreshes the specified related component

Return Value

Doctrine_Record this object

void clearRelated(string $name = null)

Clear a related reference or all references

Parameters

string $name The relationship reference to clear

Return Value

void

boolean relatedExists(string $name)

Check if a related relationship exists. Will lazily load the relationship in order to check. If the reference didn't already exist and it doesn't exist in the database, the related reference will be cleared immediately.

Parameters

string $name

Return Value

boolean Whether or not the related relationship exists

array getData()

return all the internal data (columns)

Return Value

array an array containing all the properties

mixed rawGet($fieldName)

returns the value of a property (column). If the property is not yet loaded this method does NOT load it.

Parameters

$fieldName

Return Value

mixed

Exceptions

Doctrine_Record_Exception if trying to get an unknown property

boolean load(array $data = array())

loads all the uninitialized properties from the database.

Used to move a record from PROXY to CLEAN/DIRTY state.

Parameters

array $data overwriting data to load in the record. Instance is hydrated from the table if not specified.

Return Value

boolean

boolean isInProxyState()

indicates whether record has any not loaded fields

Return Value

boolean

boolean hasAccessor(string $fieldName, string $accessor = null)

sets a fieldname to have a custom accessor or check if a field has a custom accessor defined (when called without $accessor parameter).

Parameters

string $fieldName
string $accessor

Return Value

boolean

void clearAccessor(string $fieldName)

clears the accessor for a field name

Parameters

string $fieldName

Return Value

void

string getAccessor(string $fieldName)

gets the custom accessor for a field name

Parameters

string $fieldName

Return Value

string $accessor

array getAccessors()

gets all accessors for this component instance

Return Value

array $accessors

boolean hasMutator(string $fieldName, string $mutator = null)

sets a fieldname to have a custom mutator or check if a field has a custom mutator defined (when called without the $mutator parameter)

Parameters

string $fieldName
string $mutator

Return Value

boolean

string getMutator($fieldName)

gets the custom mutator for a field name

Parameters

$fieldName

Return Value

string

void clearMutator(string $fieldName)

clears the custom mutator for a field name

Parameters

string $fieldName

Return Value

void

array getMutators()

gets all custom mutators for this component instance

Return Value

array $mutators

hasAccessorMutator($fieldName, $accessor, $mutator)

Set a fieldname to have a custom accessor and mutator

Parameters

$fieldName
$accessor
$mutator

protected _get($fieldName, $load = true)

Parameters

$fieldName
$load

void mapValue(string $name, mixed $value = null)

sets a value that will be managed as if it were a field by magic accessor and mutators, see get() and see set().

Normally used by Doctrine for the mapping of aggregate values.

Parameters

string $name the name of the mapped value
mixed $value mixed value to be mapped

Return Value

void

boolean hasMappedValue(string $name)

Tests whether a mapped value exists

Parameters

string $name the name of the property

Return Value

boolean

protected _set($fieldName, $value, $load = true)

Parameters

$fieldName
$value
$load

protected boolean _isValueModified(string $type, string $old, string $new)

Check if a value has changed according to Doctrine Doctrine is loose with type checking in the same ways PHP is for consistancy of behavior

This function basically says if what is being set is of Doctrine type boolean and something like current_value == 1 && new_value = true would not be considered modified

Simply doing $old !== $new will return false for boolean columns would mark the field as modified and change it in the database when it is not necessary

Parameters

string $type Doctrine type of the column
string $old Old value
string $new New value

Return Value

boolean $modified Whether or not Doctrine considers the value modified

coreSetRelated(string $name, Doctrine_Record|Doctrine_Collection $value)

Places a related component in the object graph.

This method inserts a related component instance in this record relations, populating the foreign keys accordingly.

Parameters

string $name related component alias in the relation
Doctrine_Record|Doctrine_Collection $value object to be linked as a related component

array getPendingDeletes()

returns Doctrine_Record instances which need to be deleted on save

Return Value

array

returns Doctrine_Record instances which need to be unlinked (deleting the relation) on save

Return Value

array $pendingUnlinks

resets pending record unlinks

Return Value

void

void save(Doctrine_Connection $conn = null)

applies the changes made to this object into database this method is smart enough to know if any changes are made and whether to use INSERT or UPDATE statement

this method also saves the related components

Parameters

Doctrine_Connection $conn optional connection parameter

Return Value

void

Exceptions

Exception if record is not valid and validation is active

TRUE trySave(Doctrine_Connection $conn = null)

tries to save the object and all its related components.

In contrast to Doctrine_Record::save(), this method does not throw an exception when validation fails but returns TRUE on success or FALSE on failure.

Parameters

Doctrine_Connection $conn optional connection parameter

Return Value

TRUE if the record was saved sucessfully without errors, FALSE otherwise.

integer replace(Doctrine_Connection $conn = null)

executes a SQL REPLACE query. A REPLACE query is identical to a INSERT query, except that if there is already a row in the table with the same key field values, the REPLACE query just updates its values instead of inserting a new row.

The REPLACE type of query does not make part of the SQL standards. Since practically only MySQL and SQLIte implement it natively, this type of query isemulated through this method for other DBMS using standard types of queries inside a transaction to assure the atomicity of the operation.

Parameters

Doctrine_Connection $conn optional connection parameter

Return Value

integer number of rows affected

Exceptions

Doctrine_Connection_Exception if some of the key values was null
Doctrine_Connection_Exception if there were no key fields
Doctrine_Connection_Exception if something fails at database level

array getModified(boolean $old = false, boolean $last = false)

retrieves an array of modified fields and associated new values.

Parameters

boolean $old pick the old values (instead of the new ones)
boolean $last pick only lastModified values (see getLastModified())

Return Value

array $a

array getLastModified(boolean $old = false)

returns an array of the modified fields from the last transaction.

Parameters

boolean $old pick the old values (instead of the new ones)

Return Value

array

array getPrepared(array $array = array())

Retrieves data prepared for a sql transaction.

Returns an array of modified fields and values with data preparation; adds column aggregation inheritance and converts Records into primary key values.

Parameters

array $array

Return Value

array

integer count()

implements Countable interface

Return Value

integer the number of columns in this record

integer columnCount()

alias for see count()

Return Value

integer the number of columns in this record

array toArray(boolean $deep = true, boolean $prefixKey = false)

returns the record representation as an array

Parameters

boolean $deep whether to include relations
boolean $prefixKey not used

Return Value

array

void merge($data, $deep = true)

merges this record with an array of values or with another existing instance of this object

Parameters

$data
$deep

Return Value

void

See also

fromArray()

void fromArray(array $array, bool $deep = true)

imports data from a php array

Parameters

array $array array of data, see link for documentation
bool $deep whether or not to act on relations

Return Value

void

synchronizeWithArray(array $array, bool $deep = true)

synchronizes a Doctrine_Record instance and its relations with data from an array

it expects an array representation of a Doctrine_Record similar to the return value of the toArray() method. If the array contains relations it will create those that don't exist, update the ones that do, and delete the ones missing on the array but available on the Doctrine_Record (unlike see fromArray() that does not touch what it is not in $array)

Parameters

array $array representation of a Doctrine_Record
bool $deep whether or not to act on relations

string exportTo(string $type, string $deep = true)

exports instance to a chosen format

Parameters

string $type format type: array, xml, yml, json
string $deep whether or not to export all relationships

Return Value

string representation as $type format. Array is $type is array

void importFrom($type, $data, $deep = true)

imports data from a chosen format in the current instance

Parameters

$type
$data
$deep

Return Value

void

boolean exists()

returns true if this record is saved in the database, otherwise false (it is transient)

Return Value

boolean

boolean isModified(boolean $deep = false)

returns true if this record was modified, otherwise false

Parameters

boolean $deep whether to process also the relations for changes

Return Value

boolean

boolean hasRelation(mixed $fieldName)

checks existence of properties and related components

Parameters

mixed $fieldName name of the property or reference

Return Value

boolean

Doctrine_Record_Iterator getIterator()

implements IteratorAggregate interface

Return Value

Doctrine_Record_Iterator iterator through data

boolean delete(Doctrine_Connection $conn = null)

deletes this data access object and all the related composites this operation is isolated by a transaction

this event can be listened by the onPreDelete and onDelete listeners

Parameters

Doctrine_Connection $conn

Return Value

boolean true if successful

Doctrine_Record copy(boolean $deep = false)

generates a copy of this object. Returns an instance of the same class of $this.

Parameters

boolean $deep whether to duplicates the objects targeted by the relations

Return Value

Doctrine_Record

void assignIdentifier(mixed $id = false)

assigns an identifier to the instance, for database storage

Parameters

mixed $id a key value or an array of keys

Return Value

void

array identifier()

returns the primary keys of this object

Return Value

array

final integer getIncremented()

returns the value of autoincremented primary key of this object (if any)

Return Value

integer

Doctrine_Record getLast()

getLast this method is used internally by Doctrine_Query it is needed to provide compatibility between records and collections

Return Value

Doctrine_Record

boolean hasReference(string $name)

tests whether a relation is set

Parameters

string $name relation alias

Return Value

boolean

Doctrine_Record|Doctrine_Collection reference(string $name)

gets a related component

Parameters

string $name

Return Value

Doctrine_Record|Doctrine_Collection

obtainReference(string $name)

gets a related component and fails if it does not exist

Parameters

string $name

Exceptions

Doctrine_Record_Exception if trying to get an unknown related component

array getReferences()

get all related components

Return Value

array various Doctrine_Collection or Doctrine_Record instances

final setRelated(string $alias, Doctrine_Access $coll)

set a related component

Parameters

string $alias
Doctrine_Access $coll

void loadReference(string $name)

loadReference loads a related component

Parameters

string $name alias of the relation

Return Value

void

Exceptions

Doctrine_Table_Exception if trying to load an unknown related component

Doctrine_Record call($callback, $column)

call

Parameters

$callback
$column

Return Value

Doctrine_Record provides a fluent interface

Doctrine_Node getNode()

getter for node associated with this record

Return Value

Doctrine_Node false if component is not a Tree

unshiftFilter(Doctrine_Record_Filter $filter)

Parameters

Doctrine_Record_Filter $filter

unlink removes links from this record to given records if no ids are given, it removes all links

Parameters

string $alias related component alias
array $ids the identifiers of the related records
boolean $now whether or not to execute now or set as pending unlinks

Return Value

Doctrine_Record this object (fluent interface)

Doctrine_Record unlinkInDb(string $alias, array $ids = array())

unlink now the related components, querying the db

Parameters

string $alias related component alias
array $ids the identifiers of the related records

Return Value

Doctrine_Record this object (fluent interface)

creates links from this record to given records

Parameters

string $alias related component alias
array $ids the identifiers of the related records
boolean $now wether or not to execute now or set pending

Return Value

Doctrine_Record this object (fluent interface)

Doctrine_Record linkInDb(string $alias, array $ids)

creates links from this record to given records now, querying the db

Parameters

string $alias related component alias
array $ids the identifiers of the related records

Return Value

Doctrine_Record this object (fluent interface)

protected void _resetModified()

Reset the modified array and store the old array in lastModified so it can be accessed by users after saving a record, since the modified array is reset after the object is saved.

Return Value

void

mixed __call(string $method, array $args)

magic method used for method overloading

the function of this method is to try to find a given method from the templates (behaviors) the record is using, and if found, execute it. Note that already existing methods would not be overloaded.

So, in sense, this method replicates the usage of mixins (as seen in some programming languages)

Parameters

string $method name of the method
array $args method arguments

Return Value

mixed the return value of the given method

deleteNode()

used to delete node from tree - MUST BE USE TO DELETE RECORD IF TABLE ACTS AS TREE

free(boolean $deep = false)

Helps freeing the memory occupied by the entity.

Cuts all references the entity has to other entities and removes the entity from the instance pool. Note: The entity is no longer useable after free() has been called. Any operations done with the entity afterwards can lead to unpredictable results.

Parameters

boolean $deep whether to free also the related components

string toString()

__toString alias

Return Value

string

string __toString()

magic method

Return Value

string representation of this object