MidCOM DBA level wrapper for the Midgard Collector.

This class must be used anyplace within MidCOM instead of the real midgard_collector object within the MidCOM Framework. This wrapper is required for the correct operation of many MidCOM services.

It essentially wraps the calls to {@link midcom_helper__dbfactory::new_collector()}.

Normally you should never have to create an instance of this type directly, instead use the new_collector() method available in the MidCOM DBA API or the midcom_helper__dbfactory::new_collector() method which is still available.

If you have to do create the instance manually however, do not forget to call the {@link initialize()} function after construction, or the creation callbacks will fail.

package midcom

 Methods

__construct (string $classname, $domain, $value)

The constructor wraps the class resolution into the MidCOM DBA system.

Currently, Midgard requires the actual MgdSchema base classes to be used when dealing with the QB, so we internally note the corresponding class information to be able to do correct typecasting later.

Parameters

$classname

stringThe classname which should be queried.

$domain

$value

add_value_property ($property)

Parameters

$property

count ()

Returns the number of elements matching the current query.

Due to ACL checking we must first execute the full query

Returns

intThe number of records found by the last query.

count_unchecked ()

This is a mapping to the real count function of the Midgard Collector.

It is mainly intended when speed is important over accuracy, as it bypasses access control to get a fast impression of how many objects are available in a given query. It should always be kept in mind that this is a preliminary number, not a final one.

Use this function with care. The information you obtain in general is negligible, but a creative mind might nevertheless be able to take advantage of it.

Returns

intThe number of records matching the constraints without taking access control or visibility into account.

destroy ()

execute ()

This function will execute the Querybuilder and call the appropriate callbacks from the class it is associated to.

This way, class authors have full control over what is actually returned to the application.

The calling sequence of all event handlers of the associated class is like this:

  1. boolean _on_prepare_exec_collector(&$this) is called before the actual query execution. Return false to abort the operation.
see \_real_execute()

Returns

booleanindicating success/failure

get ($key)

Parameters

$key

get_objects ()

get_subkey ($key, $property)

Parameters

$key

$property

get_values (string $field)

Convenience function to get all values of a specific column, indexed by GUID

Parameters

$field

stringthe column name

initialize ()

The initialization routine executes the _on_prepare_new_collector callback on the class.

This cannot be done in the constructor due to the reference to $this that is used.

list_keys ()

implements midgard_collector::list_keys with ACL checking

list_keys_unchecked ()

Runs a query where limit and offset is taken into account <i>prior</i> to execution in the core.

This is useful in cases where you can safely assume read privileges on all objects, and where you would otherwise have to deal with huge resultsets.

Be aware that this might lead to empty resultsets "in the middle" of the actual full resultset when read privileges are missing.

see \list_keys()

set_key_property ($property, $value)

Parameters

$property

$value

_list_keys_and_check_privileges ()

_real_execute ()

Executes the MC

 Properties

 

boolean $_executed

Keep track if $this->execute has been called
 

string $_user_id

This private helper holds the user id for ACL checks.

This is set when executing to avoid unnecessary overhead