Source for file test_RdqlQuery.php
Documentation is available at test_RdqlQuery.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Test Traverse Model_Memory</title>
require_once 'RDF/Model/Memory.php';
require_once 'RDF/RDQL.php';
// Filename of an RDF document
// Create a new Model_Memory
$model = & new RDF_Model_Memory ();
// Load and parse document
$model->writeAsHtmlTable ();
echo "<BR>show the age of all employees ,using the RdqlResultIterator<BR>";
(?blank, vcard:Given, ?givenName)
USING vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
v FOR <http://sampleVocabulary.org/1.3/People#>';
// query model, get RDQLResultIterator
$rdqlIter = RDF_RDQL ::RDQLQueryAsIterator ($model, $rdql_query);
// get different Result labels as array
$result_labels = $rdqlIter->getResultLabels ();
echo "<BR><b>Result Label Names:</b> ";
for ($i = 0; $i < count($result_labels); $i++ ) echo $result_labels[$i] . " ";
echo "<BR><B>Number of results:</B> " . $rdqlIter->countResults ();
echo "<BR><B>Result objects, serialized to string:</B><BR>";
// serialize result to string
while ($rdqlIter->hasNext ()) {
$curren_result = $rdqlIter->next();
for ($j = 0; $j < count($result_labels); $j++ ) echo $curren_result[$result_labels[$j]]->toString () . "<BR> ";
// show emails of all employees
SELECT ?givenName, ?familyName, ?email
WHERE (?person vcard:N ?blank1)
(?blank1 vcard:Given ?givenName)
(?blank1 vcard:Family ?familyName)
(?person vcard:EMAIL ?blank2)
(?blank2 rdf:value ?email)
AND ?person ~~ "/example.com\/EMPLOYEES\//i"
USING vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
v FOR <http://sampleVocabulary.org/1.3/People#>';
$res = RDF_RDQL ::RDQLQuery ($model, $rdql_query);
echo "<br>show all employees over 30 <BR>";
// show all employees over 30
WHERE (?x, vcard:FN, ?employee), (?x, v:age, ?age)
USING vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
v FOR <http://sampleVocabulary.org/1.3/People#>';
$res = RDF_RDQL ::RDQLQuery ($model, $rdql_query);
// find out whose number is it: +1 111 2212 431
WHERE (?x, vcard:TEL, ?tel),
(?tel, rdf:value, ?telNumber)
AND ?telNumber eq "+1 111 2212 431"
USING vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
v FOR <http://sampleVocabulary.org/1.3/People#>';
$res = RDF_RDQL ::RDQLQuery ($model, $rdql_query);
// show office telephone numbers of all employees
SELECT ?givenName, ?familyName, ?telNumber
WHERE (?person vcard:N ?blank1)
(?blank1 vcard:Given ?givenName)
(?blank1 vcard:Family ?familyName)
(?person vcard:TEL ?blank2)
(?blank2 rdf:value ?telNumber)
AND ?person ~~ "/example.com\/EMPLOYEES\//i" && ?type eq vcard:work
USING vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
v FOR <http://sampleVocabulary.org/1.3/People#>';
$res = RDF_RDQL ::RDQLQuery ($model, $rdql_query);
Documentation generated on Mon, 11 Mar 2019 15:39:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|