Пример #1
0
 /**
  * Remove a statement from the model.
  *
  * @param   LibRDF_Statement    $statement  The statement to remove
  * @param   LibRDF_URINode      $context    The context from which to remove the statement
  * @return  void
  * @throws  LibRDF_Error        If unable to remove the statement
  * @access  public
  */
 public function removeStatement(LibRDF_Statement $statement, LibRDF_URINode $context = NULL)
 {
     if ($context != NULL) {
         $context = $context->getNode();
         $ret = librdf_model_context_remove_statement($this->model, $context, $statement->getStatement());
     } else {
         $ret = librdf_model_remove_statement($this->model, $statement->getStatement());
     }
     if ($ret) {
         throw new LibRDF_Error("Unable to remove statement");
     }
 }
Пример #2
0
 function remove_triple($triple)
 {
     if (!isset($triple['type']) || $triple['type'] != 'triple') {
         return 0;
     }
     $r = 0;
     $s = $triple['s'];
     $p = $triple['p'];
     $o = $triple['o'];
     if (!is_null($s)) {
         $s = $this->_uriNode($s);
     }
     if (!is_null($p)) {
         $p = $this->_uriNode($p);
     }
     if (!is_null($o)) {
         if ($triple['o_type'] == 'uri') {
             $o = $this->_uriNode($o);
         } elseif ($triple['o_type'] == 'literal') {
             $o = $this->_literalNode($o);
         }
     }
     $pattern = librdf_new_statement_from_nodes($this->_world, $s, $p, $o);
     $stream = librdf_model_find_statements($this->_model, $pattern);
     while (!librdf_stream_end($stream)) {
         $elt = librdf_stream_get_object($stream);
         $r += librdf_model_remove_statement($this->_model, $elt) ? 0 : 1;
         librdf_stream_next($stream);
     }
     librdf_free_stream($stream);
     //librdf_free_statement($pattern);
     //$s && librdf_free_node($s);
     //$p && librdf_free_node($p);
     return $r;
 }