Exemplo n.º 1
0
print "Querying for dc:titles:\n";
$results = librdf_model_query_execute($model, $query);
$count = 1;
while ($results && !librdf_query_results_finished($results)) {
    print "result {$count}: {\n";
    for ($i = 0; $i < librdf_query_results_get_bindings_count($results); $i++) {
        $val = librdf_query_results_get_binding_value($results, $i);
        if ($val) {
            $nval = librdf_node_to_string($val);
        } else {
            $nval = '(unbound)';
        }
        print "  " . librdf_query_results_get_binding_name($results, $i) . "=" . $nval . "\n";
    }
    print "}\n";
    librdf_query_results_next($results);
    $count++;
}
if ($results) {
    print "Returned {$count} results\n";
}
$results = null;
print "\nExecuting query again\n";
$results = librdf_model_query_execute($model, $query);
if ($results) {
    $str = librdf_query_results_to_string($results, null, null);
    print "Query results serialized to an XML string size " . strlen($str) . " bytes\n";
} else {
    print "Query results couldn't be serialized to an XML string\n";
}
$serializer = librdf_new_serializer($world, 'rdfxml', null, null);
Exemplo n.º 2
0
 /**
  * Advance the iterator.
  *
  * @return  void
  * @access  public
  */
 public function next()
 {
     if ($this->isvalid) {
         $this->rewindable = false;
         $ret = librdf_query_results_next($this->query_results);
         if ($ret) {
             $this->isvalid = false;
         } else {
             $this->key++;
         }
     }
 }