Basic DBO properties and methods | |
| $id | |
| [int|null] DBO ID (same as in DB). | |
| $def | |
| [dbo_def] DBO definition object. | |
| __construct ($no_session=false) | |
| Constructor. | |
| remove () | |
| Mark DBO for removal on next commit. | |
| changed () | |
| Check if DBO attributes differ from stored state. | |
| dump ($level=2, $prefix= '') | |
| Dump DBO data. | |
| static | get () |
| Get single DBO from DB by ID or SQL query. | |
| static | query () |
| Get multiple DBOs from DB using SQL query. | |
Advanced DBO methods | |
| attr_get ($name) | |
| Get current value of attribute. | |
| attr_set ($name, $value) | |
| Set attribute. | |
| attr_init ($name, $value) | |
| Initialize attribute. | |
| attr_reset ($name) | |
| Reset attribute to its original value. | |
| attr_isset ($name) | |
| Check if current value of attribute differs from its origianl value. | |
| attr_add_message ($name, $message) | |
| Associate error message with particular attribute. | |
| attr_get_messages ($name) | |
| Get array of messages associated with given attribute. | |
| add_message ($message) | |
| Associate message with whole entity. | |
| get_messages () | |
| Get array of messages associated with whole entity. | |
| has_messages () | |
| Check if entity, its attributes or bags have associated any messages with it. | |
| reset_messages () | |
| Remove all messages. | |
| attr_check (dbo_attr_def $def) | |
| Check single attribute value. | |
| attr_check_custom (dbo_attr_def $def, $value) | |
| Override this method to implement custom attribute validity checks. | |
| check () | |
| Check validity of attributes and bag constraints. | |
| hook ($name) | |
| Hook for various situations. | |
This class implements basic DBO functionality:
| dbo::__construct | ( | $ | no_session = false |
) |
Constructor.
Initialize bags, attrs.
| no_session | [boolean] Whether to put new DBO into session or not. |
Reimplemented in news_item, news_subscriber, and news_category.
References dbo_manager::get_session(), and hook().
| dbo::add_message | ( | $ | message | ) |
Associate message with whole entity.
| message | [string] Message text. |
| dbo::attr_add_message | ( | $ | name, | |
| $ | message | |||
| ) |
Associate error message with particular attribute.
| name | [string] Attribute name. | |
| message | [string] Message text. |
| dbo::attr_check | ( | dbo_attr_def $ | def | ) |
Check single attribute value.
| def | [dbo_attr_def] Attribute definition. |
| dbo::attr_check_custom | ( | dbo_attr_def $ | def, | |
| $ | value | |||
| ) |
Override this method to implement custom attribute validity checks.
| def | [dbo_attr_def] Attribute definition. | |
| value | [mixed] Attribute value. |
| dbo::attr_get | ( | $ | name | ) |
Get current value of attribute.
| name | [string] Attribute name. |
Referenced by dump().
| dbo::attr_get_messages | ( | $ | name | ) |
Get array of messages associated with given attribute.
| name | [string] Attribute name. |
Referenced by dump().
| dbo::attr_init | ( | $ | name, | |
| $ | value | |||
| ) |
Initialize attribute.
This will set current and original attribute values.
| name | [string] Attribute name. | |
| value | [any] Attribute value. |
| dbo::attr_isset | ( | $ | name | ) |
Check if current value of attribute differs from its origianl value.
| name | [string] Attribute name. |
Referenced by changed().
| dbo::attr_reset | ( | $ | name | ) |
Reset attribute to its original value.
| name | [string] Attribute name. |
| dbo::attr_set | ( | $ | name, | |
| $ | value | |||
| ) |
Set attribute.
| name | [string] Attribute name. | |
| value | [mixed] Attribute value. |
| dbo::changed | ( | ) |
Check if DBO attributes differ from stored state.
References attr_isset().
| dbo::check | ( | ) |
Check validity of attributes and bag constraints.
This method has side effect of setting messages on attributes, whole DBO and bags. You should call reset_messages() before calling this method.
| dbo::dump | ( | $ | level = 2, |
|
| $ | prefix = '' | |||
| ) |
Dump DBO data.
| level | [int] Maximum depth of dump (prevents recursion, limits useless output). | |
| prefix | [string] For internal use. (dump lines prefix) |
References attr_get(), attr_get_messages(), and get_messages().
| static dbo::get | ( | ) | [static] |
Get single DBO from DB by ID or SQL query.
This method can be used to get single object from database. You can call it in following ways:
If DBO was already instantiated in active session, instance from the session will be returned. Thus you can never end up with multiple instances of DBO refering to same row in DB in one session.
Reimplemented in news_item, news_subscriber, and news_category.
References $def, and dbo_manager::get_session().
Referenced by query().
| dbo::get_messages | ( | ) |
Get array of messages associated with whole entity.
Referenced by dump().
| dbo::has_messages | ( | ) |
Check if entity, its attributes or bags have associated any messages with it.
| dbo::hook | ( | $ | name | ) |
Hook for various situations.
Override this method to implement custom actions for following situations:
| name | [string] Hook name. |
Referenced by __construct(), and remove().
| static dbo::query | ( | ) | [static] |
Get multiple DBOs from DB using SQL query.
This method can be used to query array of objects from database. You can call it in following ways:
| dbo::remove | ( | ) |
Mark DBO for removal on next commit.
This will also mark all DBOs owned by this DBO.
References hook().
| dbo::reset_messages | ( | ) |
Remove all messages.
| dbo::$id |
[int|null] DBO ID (same as in DB).
Null for DBOs not yet in DB.