Newsletterdeveloper's documentation

dbo_bag Class Reference
[DBO Core API]

DBO bag is container object that is used to implement entity relations. More...

List of all members.
 $def
 [dbo_bag_def] Bag description object.
 __construct (dbo $owner, dbo_bag_def $def)
 Constructor.
 load ($full=false)
 Load information into bag.
 add ()
 Add object into the bag.
 set ()
 Add object into the bag and remove existing ones.
 find_object_index ($obj)
 Find object's index in the bag by object instance.
 find_oid_index ($oid)
 Find object's index in the bag by ID.
 find_index ($arg)
 Find index of object or OID in the bag.
 find_object ($oid)
 Find object in the bag by its OID.
 count ()
 Get number of items in the container.
 create ()
 Create new item and add it to the bag.
 move_object_after ($id, $ref_id)
 Move object with id after object with ref_id.
 remove_all ($deep=false)
 Remove all objects from the bag.
 remove ($index, $deep=false)
 Remove one object from the bag.
 get ($index=null)
 Get DBO from the container using it's index.
 get_single ()
 Get single DBO from the container.
 get_iterator ()
 Get DBO objects iterator for bag items.
 get_ids_iterator ()
 Get DBO objects ID iterator for bag items.
 check ()
 Check bag for constraints.
 move_index_after ($item_idx, $after_idx)
 Move item with index $item_idx after item with index $after_idx.
 changed ()
 Check if DBO bag differs from the stored state.
 dump ()
 Dump internal data.


Detailed Description

DBO bag is container object that is used to implement entity relations.

It can be in following states:


Constructor & Destructor Documentation

dbo_bag::__construct ( dbo owner,
dbo_bag_def def 
)

Constructor.

Parameters:
owner [dbo] Bag owner.
def [dbo_bag_def] DBO bag description.


Member Function Documentation

dbo_bag::add (  ) 

Add object into the bag.

Parameters to this function may be:

  • add($obj)
  • add(1) --> add(item_type::get(1))
  • add("WHERE name = ?", "name") --> add(item_type::get("WHERE name = ?", "name"))
Returns:
[dbo] Added object.
Exceptions:
Exception on any error.

References count(), find_object_index(), and load().

dbo_bag::changed (  ) 

Check if DBO bag differs from the stored state.

Returns:
[boolean] TRUE if bag differs from stored state.

References count().

dbo_bag::check (  ) 

Check bag for constraints.

Returns:
[boolean] True if everything is ok, false otherwise. If this function returns false $this->message is updated with error message, otherwise it is cleared.

References count().

dbo_bag::count (  ) 

Get number of items in the container.

Returns:
[int] Number of items.

References load().

Referenced by add(), changed(), check(), and get_single().

dbo_bag::create (  ) 

Create new item and add it to the bag.

Returns:
[dbo] DBO.
Exceptions:
Exception on error.

dbo_bag::dump (  ) 

Dump internal data.

Useful for debugging.

Returns:
[string] Data string.

dbo_bag::find_index ( arg  ) 

Find index of object or OID in the bag.

Parameters:
arg [int|dbo] Argument (OID or object).
Returns:
[int|null] Index.
Exceptions:
Exception on error.

References find_object_index(), and find_oid_index().

Referenced by move_object_after().

dbo_bag::find_object ( oid  ) 

Find object in the bag by its OID.

Parameters:
oid [int] Object ID.
Returns:
[dbo|null] Object.
Exceptions:
Exception on error.

References find_oid_index().

dbo_bag::find_object_index ( obj  ) 

Find object's index in the bag by object instance.

Parameters:
obj [dbo] DBO instance.
Returns:
[int|null] Index or null.

References load().

Referenced by add(), and find_index().

dbo_bag::find_oid_index ( oid  ) 

Find object's index in the bag by ID.

Parameters:
oid [int] Object ID.
Returns:
[int|null] Index or null.

References load().

Referenced by find_index(), and find_object().

dbo_bag::get ( index = null  ) 

Get DBO from the container using it's index.

Parameters:
index [int] Index of the item.
Returns:
[dbo] DBO on that index.

References get_single(), and load().

dbo_bag::get_ids_iterator (  ) 

Get DBO objects ID iterator for bag items.

This function does not return objects that are not yet in DB.

Returns:
[ArrayIterator] Bag item IDs iterator [int].

References load().

dbo_bag::get_iterator (  ) 

Get DBO objects iterator for bag items.

Returns:
[ArrayIterator] Bag items iterator [dbo].

References load().

dbo_bag::get_single (  ) 

Get single DBO from the container.

Returns:
[dbo] DBO.

References count(), and load().

Referenced by get().

dbo_bag::load ( full = false  ) 

Load information into bag.

We are sure that objects array is always empty when this function is called and state is INIT.

Parameters:
full [boolean] If true, bag is loaded fully. If false, only object ids are loaded.

Referenced by add(), count(), find_object_index(), find_oid_index(), get(), get_ids_iterator(), get_iterator(), get_single(), remove(), and remove_all().

dbo_bag::move_index_after ( item_idx,
after_idx 
)

Move item with index $item_idx after item with index $after_idx.

Parameters:
item_idx [string] Item index.
after_idx [string] Reference item index.

Referenced by move_object_after().

dbo_bag::move_object_after ( id,
ref_id 
)

Move object with id after object with ref_id.

Parameters:
id [int] Object ID.
ref_id [int|null] If null, then move at the end, if -1 than at the beginning.

References find_index(), and move_index_after().

dbo_bag::remove ( index,
deep = false 
)

Remove one object from the bag.

Parameters:
index [int] Index of the object that should be removed.
deep [boolean] If true, objects are also removed using dbo::remove(), otherwise only their link to the bag is removed.
Returns:
[dbo] Removed object.

References load().

dbo_bag::remove_all ( deep = false  ) 

Remove all objects from the bag.

Parameters:
deep [boolean] If true, objects are also removed using dbo::remove(), otherwise only their link to the bag is removed.

References load().

Referenced by set().

dbo_bag::set (  ) 

Add object into the bag and remove existing ones.

Parameters to this function are same as to dbo_bag::add().

Returns:
[dbo] Added object.
Exceptions:
Exception on any error.

References remove_all().


Member Data Documentation

dbo_bag::$def

[dbo_bag_def] Bag description object.


The documentation for this class was generated from the following file:
Documentation for Newsletter, Tue Nov 11 07:50:02 2008.