Open Source Content Management System

PHP midgard_collector method set_key_property

  1. Example

Sets property name as collector's key.

bool set_key_property(string 'key', [mixed value]);

midgard_collector method set_key_property takes two parameters:

  • key, property name which should be used as collector's key
  • value, optional value if returned keys should be limited to defined value

When second optional value parameter is ommited collector query all records with key property, otherwise collector's array is limited to only these records for which key's value is equal.

Returns TRUE is key was succesfully assigned to collector, otherwise returns FALSE.

Cases to return FALSE:

  • Key property is not registered for the classname for which collector object has been initialized
  • Value has invalid type ( e.g. property's value registered as string and integer passed as fynction argument )
  • Key has been already assigned to collector's instance.

More details about fails can be found in midgard-core docs.

Example

<?php

/* Query all names of midgard_parameter where parentguid points to $guid 
 * value and domain is equal to 'midcom' 
 */  
$mc = new midgard_collector("midgard\_parameter", "parentguid", $guid);
$mc->set_key_property("domain", "midcom");
$mc->add_value_property("name");
$mc->execute();
?>
Designed by Nemein, hosted by Anykey