PersistentPoolStorage: Difference between revisions

From Sunhill Framework Documentation
page created
 
more information
Line 4: Line 4:


== doCommit(array $structure) ==
== doCommit(array $structure) ==
Performs the transfer to the persistent storage (like database, file, etc.).


== doRollback() ==
For the parameter $structure see [[#structure]]


== doMigrate(array $structure) ==
== doMigrate(array $structure) ==
Optional. By default it does nothing. This method should prepare the persistent storage to store values to it (like creating database tables, files, etc.)
For the parameter $structure see [[#Structure]]
== Structure ==
The above functions take an array parameter called $structure. This array contains the structure of the owning property. The elements of the array are a stdClass with following members:
* '''name''': A string parameter that holds the name of this property
* '''type''': The primitive type (like integer, date, string, etc.) of this property
* '''property_class''': The full qualified name of the owning property class. This is important for the objects.
Depending on type there could be some additional members that give additional information
* '''string'''
** '''max_length''': The maximum length that the string could take
* '''array'''
** '''element_type''': The type of a element of the array.


[[Category:Storages]]
[[Category:Storages]]

Revision as of 12:14, 12 October 2024

The PerstentStorage is the base for all storages that can write itself to some kind of persistent storage (like a harddisk or a database). This storages fills the dummy methods commit(), rollback() and isDirty() with some life.

The persistent storage takes care of tracking changes to values. You only have to overwrite a few methods:

doCommit(array $structure)

Performs the transfer to the persistent storage (like database, file, etc.).

For the parameter $structure see #structure

doMigrate(array $structure)

Optional. By default it does nothing. This method should prepare the persistent storage to store values to it (like creating database tables, files, etc.)

For the parameter $structure see #Structure

Structure

The above functions take an array parameter called $structure. This array contains the structure of the owning property. The elements of the array are a stdClass with following members:

  • name: A string parameter that holds the name of this property
  • type: The primitive type (like integer, date, string, etc.) of this property
  • property_class: The full qualified name of the owning property class. This is important for the objects.

Depending on type there could be some additional members that give additional information

  • string
    • max_length: The maximum length that the string could take
  • array
    • element_type: The type of a element of the array.