webCOMAND

repo::get_objects_by_id()

Retrieve multiple objects of the same content type from the repository by their ID.

Prototype

array get_objects_by_id(array $ids, mixed $content_type)

Parameters

  • ids - Array of Object IDs.
  • content_type - The Content Type identified by the content type object or the Content Type Identifier as a string.

Return

An array of zero or more cObjects that match the specified IDs and content_type.  If none or only some of the IDs have a match, only those that match will be returned.  Non-matching IDs will simply be ignored, so you may want to compare the count of the returned array to the count of ids to verify all IDs match.

Example

$ids = [123, 456];
$contacts = $repo->get_objects_by_id($ids, 'Contact');
if(count($contacts) !== count($ids) {
    echo("Some IDs did not match\n");
    exit();
}
foreach($contacts as $contact) {
    echo($contact->FirstName . " " . $contact->LastName . "\n");
}

Related

get_object_by_id(), get_objects_by_oid(), get_objects_by_doid(), get_objects_by_uuid(), get()