Example #1
0
 protected function countTriples(NamedNode $graph)
 {
     $result = $this->fixture->query('SELECT COUNT(?s) as ?count FROM <' . $graph->getUri() . '> WHERE {?s ?p ?o}');
     $variables = $result->getVariables();
     $variable = array_shift($variables);
     $entry = $result->current();
     return $entry[$variable]->getValue();
 }
Example #2
0
 /**
  * Removes the given graph from the store.
  *
  * @param  NamedNode  $graph            Instance of NamedNode containing the URI of the graph to drop.
  * @param  array      $options optional It contains key-value pairs and should provide additional
  *                                      introductions for the store and/or its adapter(s).
  * @throws \Exception If the given graph could not be droped
  */
 public function dropGraph(NamedNode $graph, array $options = array())
 {
     // table names
     $g2t = $this->configuration['table-prefix'] . '_g2t';
     $id2val = $this->configuration['table-prefix'] . '_id2val';
     /*
      * ask for all entries with the given graph URI
      */
     $query = 'SELECT id FROM ' . $id2val . ' WHERE val = "' . $graph->getUri() . '"';
     $result = $this->store->queryDB($query, $this->store->getDBCon());
     /*
      * go through all given entries and remove all according entries in the g2t table
      */
     while ($row = $result->fetch_assoc()) {
         $query = 'DELETE FROM ' . $g2t . ' WHERE t="' . $row['id'] . '"';
         $this->store->queryDB($query, $this->store->getDBCon());
     }
     // remove entry/entries in the id2val table too
     $query = 'DELETE FROM ' . $id2val . ' WHERE val = "' . $graph->getUri() . '"';
     $this->store->queryDB($query, $this->store->getDBCon());
 }
Example #3
0
 /**
  * Removes the given graph from the store.
  *
  * @param  NamedNode  $graph            Instance of NamedNode containing the URI of the graph to drop.
  * @param  array      $options optional It contains key-value pairs and should provide additional
  *                                      introductions for the store and/or its adapter(s).
  * @throws \Exception If given $graph is not a NamedNode.
  * @throws \Exception If the given graph could not be droped
  */
 public function dropGraph(NamedNode $graph, array $options = array())
 {
     if ($graph->isNamed()) {
         $this->query('DROP SILENT GRAPH <' . $graph->getUri() . '>');
     } else {
         throw new \Exception('Given $graph is not a NamedNode.');
     }
 }