webCOMAND

repo::get_objects_by_oid()

Retrieve multiple objects from the repository by their OID, optionally ensuring they match or extend a given content type.

Prototype

array get_objects_by_oid(array $oids, mixed $content_type = NULL)

Parameters

  • oids - Array of Object OIDs.
  • content_type - Optional Content Type identified by a content type object, the Content Type numeric ID or string Identifier.

Return

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

Example

$oids = [123456, 456789];
$contacts = $repo->get_objects_by_oid($oids, 'Contact');
if(count($contacts) !== count($oids) {
    echo("Some OIDs or object types did not match.\n");
    exit();
}
foreach($contacts as $contact) {
    echo($contact->FirstName . " " . $contact->LastName . "\n");
}

Related

get_object_by_oid(), get_objects_by_doid(), get_objects_by_uuid(), get_objects_by_id(), get()