You are here

function _rdfx_query_find_first in RDF Extensions 7.2

1 call to _rdfx_query_find_first()
_rdfx_query_ask in ./rdfx.query.inc
@file Functions for querying with SPARQL or extracting triples from an ARC2-style data structure.

File

./rdfx.query.inc, line 75
Functions for querying with SPARQL or extracting triples from an ARC2-style data structure.

Code

function _rdfx_query_find_first(&$model, $s, $p, $o) {
  foreach ($model as $triple) {
    if (!is_null($s) && $s != '?' && ($triple['s'] != $s || $triple['s_type'] != 'uri')) {
      continue;
    }
    if (!is_null($p) && $p != '?' && $triple['p'] != $p) {
      continue;
    }
    if (!is_null($o) && $o != '?' && ($triple['o'] != $o || $triple['o_type'] != 'uri')) {
      continue;
    }
    return $triple;
  }
  return null;
}