<<css mode="next" class="sidebar"></css>> (((
- '''<a href="/docs/fORMOrdering">Class Documentation</a>''' - <a href="/api/fORMOrdering">API Reference</a> - <a href="https://github.com/flourishlib/flourish-classes/blob/master/fORMOrdering.php" target="_blank">Source Code</a>
<<toc></toc>>
- fActiveRecord - fRecordSet
- fORM - fORMColumn - fORMDatabase - fORMDate - fORMFile - fORMJSON - fORMMoney - '''fORMOrdering''' - fORMRelated - fORMSchema - fORMValidation
)))
The fORMOrdering class is an ORM plugin to provide record ordering functionality for fActiveRecord classes.
An ordering column is used to provide arbitrary ordering for fActiveRecord objects. For a column to be an ordering column, it must be an integer column that allows for negative numbers and is part of a `UNIQUE` constraint. While an ordering value will never be negative, negative integers are used in the process of re-arranging values.
If the column is the only column in the `UNIQUE` constraint, all records in the table will be part of one ordered set. If the column is part of a multi-column `UNIQUE` constraint, all records that have the same values for each column other than the ordering will be part of an ordered set.
To configure a column to be treated as an ordering column, the static method ::configureOrderingColumn() must be called with the `$class` to configure and the `$column` to set as an ordering column.
Once a column has been set to be an ordering column, any new records inserted into the set will be automatically added at the end, unless a specific value is set for the ordering column.
Whenever the value for the ordering column is changed, the records around it will be adjusted so there is always a continuous sequence of order numbers.
Below is an example of a multi-column `UNIQUE` constraint and the dynamics related to it. Each photo is part of a photo gallery, thus it is desired to have a separate ordering for each gallery. Flourish will automatically detect that the `display_order` column is in a `UNIQUE` constraint with `photo_gallery_id` and will order each photo gallery separately.
The following example shows how photos will be ordered in their respective galleries.
If the gallery was changed for `$photo` to `Gallery 2`, it would be moved out of the display order of `Gallery 1` and added to the end of the display order for `Gallery 2`.