Skip to content
flack edited this page Dec 7, 2016 · 1 revision

Collector is a Midgard query API which works similar to Query Builder. The main difference between the two is that Collector doesn't return MgdSchema objects as results, but an array with user-definable keys. Thus, it is well-suited for performance-critical sections of code.

Example

$mc = new midgard_collector('midgard_article', 'topic', 123);
$mc->add_constraint('name', '<>', "index");
$mc->set_key_property('id');
$mc->add_value_property('title');
$mc->execute();
foreach ($mc->list_keys() as $key => $empty)
{
    echo $mc->get_subkey($key, 'title');
}

In MidCOM, collector should always be called via the DBA class, so that ACL checks can be executed.

Links

http://www.midgard-project.org/documentation/php-midgard_collector/

Clone this wiki locally