fORMDatestatic classv1.0.0b6

Provides additional date/time functionality for fActiveRecord classes

Changes:
1.0.0b6Fixed an issue with calling a non-existent method on fTimestamp instances 11/3/09
1.0.0b5Updated code for the new fORMDatabase and fORMSchema APIs 10/28/09
1.0.0b4Fixed setting up the inspect callback in configureTimezoneColumn() 10/11/09
1.0.0b3Updated to use new fORM::registerInspectCallback() method 7/13/09
1.0.0b2Updated code to use new fValidationException::formatField() method 6/4/09
1.0.0bThe initial implementation 9/5/08

Static Methods

::configureDateCreatedColumn() public

Sets a column to be a date created column

When a new record is stored in the database, date created columns will be filled with the timestamp of the store operation.

Signature

void configureDateCreatedColumn( mixed $class, string $column )

Parameters

mixed $class The class name or instance of the class
string $column The column to set as a date created column

::configureDateUpdatedColumn() public

Sets a column to be a date updated column

Whenever a record is stored in the database, a date updated column will be set to the timestamp of the operation.

Signature

void configureDateUpdatedColumn( mixed $class, string $column )

Parameters

mixed $class The class name or instance of the class
string $column The column to set as a date updated column

::configureTimezoneColumn() public

Sets a timestamp column to store the timezone in another column

Since not all databases support timezone information in timestamp columns, this method allows storing the timezone in another columns. When the timestamp and timezone are retrieved from the database, they will be automatically combined together into an fTimestamp object.

Signature

void configureTimezoneColumn( mixed $class, string $timestamp_column, string $timezone_column )

Parameters

mixed $class The class name or instance of the class to set the column format
string $timestamp_column The timestamp column to store the timezone for
string $timezone_column The column to store the timezone in

::inspect() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Adds metadata about features added by this class

Signatures

void inspect( string $class, string $column )

void inspect( array $metadata )

Parameters

string $class The class being inspected
string $column The column being inspected
array &$metadata The array of metadata about a column

::makeTimestampObjects() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Creates fTimestamp objects for every timestamp/timezone combination in the object

Signatures

void makeTimestampObjects( fActiveRecord $object )

void makeTimestampObjects( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record

::objectifyTimestampWithTimezone() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Turns a timestamp value into an fTimestamp object with a timezone specified by another column

Signatures

void objectifyTimestampWithTimezone( string $timestamp_column, string $timezone_column )

void objectifyTimestampWithTimezone( array $values, array $old_values )

Parameters

array &$values The current values
array &$old_values The old values
string $timestamp_column The column holding the timestamp
string $timezone_column The column holding the timezone

::reset() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Resets the configuration of the class

Signature

void reset( )

::setDateCreated() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the appropriate column values to the date the object was created (for new records)

Signatures

void setDateCreated( fActiveRecord $object )

void setDateCreated( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record

::setDateUpdated() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the appropriate column values to the date the object was updated

Signatures

void setDateUpdated( fActiveRecord $object )

void setDateUpdated( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record

::setTimestampColumn() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the timestamp column and then tries to objectify it with an related timezone column

Signatures

void setTimestampColumn( fActiveRecord $object, string $method_name, array $parameters )

void setTimestampColumn( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
string $method_name The method that was called
array $parameters The parameters passed to the method

::setTimezoneColumn() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the timezone column and then tries to objectify the related timestamp column

Signatures

void setTimezoneColumn( fActiveRecord $object, string $method_name, array $parameters )

void setTimezoneColumn( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
string $method_name The method that was called
array $parameters The parameters passed to the method

::validateTimezoneColumns() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Validates all timestamp/timezone columns

Signatures

void validateTimezoneColumns( fActiveRecord $object )

void validateTimezoneColumns( array $values, array $old_values, array $related_records, array $cache, array $validation_messages )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
array &$validation_messages An array of ordered validation messages