Location: PHPKode > scripts > RDQL DB > rdql-db/example.php
<?
// CHANGE THIS TO POINT TO YOUR MYSQL DATABASE
mysql_connect("localhost","root","");
mysql_select_db("rdqldb");
?>
<html>
<head>
  <title>RDQL test</title>
</head>
<body>
<div align="center">
<?php
include_once("class_rdql_db.php");

$rdqldb = new RDQL_db();
$rdqldb->set_warning_mode(true);
$rdqldb->store_rdf_document("people.rdf","people");
$rdqldb->store_rdf_document("salaries.rdf","salaries");

print("<h1>RDQL test</h1><br/>\n");
$query[0]='SELECT ?z
FROM <people>
WHERE (?x,<dt:members>,?y),(?y,?w,?z)
AND ?z<>"http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag" && ?x=="http://foo.org/team"
USING dt for <http://foo.org#>, rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>';        
$query[1]='SELECT ?x,?y
FROM <salaries>
WHERE (?x,<dt:salary>,?y)
AND ?y>200
USING dt for <http://foo.org#>, rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>';        
$query[2]='SELECT ?x,?y,?z
FROM <people>,<salaries>
WHERE (?x,<dt:salary>,?y),(?x,<dt:age>,?z)
AND ?y>200
USING dt for <http://foo.org#>, rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>';        
$query[3]='SELECT ?x,?y
FROM *
WHERE (?x,<dt:friend>,?y),(?x,<dt:salary>,?z),(?y,<dt:salary>,?w)
AND ?z>?w
USING dt for <http://foo.org#>, rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>';        


foreach($query as $a_query) {
  $head=false;
  $rows = RDQL_query_db::rdql_query_db($a_query);
  print("<table border='1' width='80%'>");
  print("<tr><td bgcolor='#aaaacc'>Query:</td></tr>");
  $a_query=str_replace("<","&lt;",$a_query);
  $a_query=str_replace(">","&gt;",$a_query);
  print("<tr><td bgcolor='#ccccee'><pre>$a_query</pre></td></tr>");
  print("</table>");
  print("<b>Result:</b>");
  print("<table border='1'width='80%'>");
  foreach($rows as $row) {
    if(!$head) {
      print("<tr>");
      foreach(array_keys($row) as $k) {
        print("<td bgcolor='#bbbbbb'><b>$k</b></td>");
      }
      print("</tr>");
      $head=true; 
    }
    print("<tr>");
    foreach($row as $key=>$val) {
      print("<td bgcolor='#dddddd'>$val</td>");
    }
    print("</tr>");
  }
  print("</table>");
  print("<br/>");
}

$data = $rdqldb->get_rdf_document("people");
//print($data);
$rdqldb->remove_rdf_document("people");
$rdqldb->remove_rdf_document("salaries");
?>
</div>
</body>
</html>
Return current item: RDQL DB