Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Resource Helper Class

semsol edited this page · 1 revision

While ARC is mainly based on array structures, it also supports a basic "Resource" helper class for convenient access to elements in an ARC resource index. The resource class can auto-fetch and cache Linked Data, use a passed list of predicates/objects, or query an ARC RDF store (local or remote).

Instantiation

$conf = array(
  'ns' => array(
    'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
    'rdfs => 'http://www.w3.org/2000/01/rdf-schema#',
    'dbpedia' => 'http://dbpedia.org/ontology/'
  ),
  ...
);
$res = ARC2::getResource($conf);

Setting the current URI (pointer)

$res->setURI('http://dbpedia.org/resource/Madrid');

Retrieving a single predicate value

If no store or predicate array is set (see below), the resource object will automatically retrieve RDF data from the resource URI.

$population = $res->getPropValue('dbpedia:populationTotal');

Setting the predicates/objects manually

$props = array(
  "http://xmlns.com/foaf/0.1/name" => array(...),
  ...
);
$res->setProps($props);

Telling the resource to fetch data from an RDF store

$store = ARC2::getStore($conf);
$res->setStore($store);

Retrieving all values for a given predicate

$labels = $res->getPropValues('rdfs:label');

Retrieving all predicates and objects (datatype and language information preserved)

$props = $res->getProps();
$labels_full = $res->getProps('rdfs:label');

Checking the existence of a certain property value

$is_eu_capital = $res->hasPropValue('rdf:type', 'http://dbpedia.org/class/yago/CapitalsInEurope');
Something went wrong with that request. Please try again.