Flourish PHP Unframework

fORMDate

static class, v1.0.0b9

Provides additional date/time functionality for fActiveRecord classes

Changes:
1.0.0b9Updated code to work with the new fORM API 8/6/10
1.0.0b8Changed validation messages array to use column name keys 5/26/10
1.0.0b7Fixed the set methods to return the record object in order to be consistent with all other set methods 3/15/10
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

Signature

void inspect( string $class, string $column, 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

Signature

void makeTimestampObjects( fActiveRecord $object, 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

Signature

void objectifyTimestampWithTimezone( array &$values, array &$old_values, string $timestamp_column, string $timezone_column )

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)

Signature

void setDateCreated( fActiveRecord $object, 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

Signature

void setDateUpdated( fActiveRecord $object, 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

Signature

fActiveRecord setTimestampColumn( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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

Returns

The record object, to allow for method chaining

::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

Signature

fActiveRecord setTimezoneColumn( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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

Returns

The record object, to allow for method chaining

::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

Signature

void validateTimezoneColumns( fActiveRecord $object, 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