-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTools.php
41 lines (35 loc) · 980 Bytes
/
Tools.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
class Tools
{
public static function count(){
global $modeDebug,$modeVerbose,$ENDPOINT;
$ENDPOINT->ResetErrors();
$q = 'SELECT (COUNT(?s) AS ?count) WHERE {GRAPH ?g { ?s ?p ?v .}} ';
$res = $ENDPOINT->query($q, 'row');
$err = $ENDPOINT->getErrors();
if ($err) {
return -1;
}
return $res["count"]; //todo trycatch //test with sesame */
}
public static function printNbTriples(){
$nbTriples = Tools::count();
return ($nbTriples < 0)? "Error read the number of triples(see Debug)":$nbTriples." triples";
}
public static function loadData($endpoint,$urldata,$graph = "DEFAULT"){
global $modeDebug,$modeVerbose;
$endpoint->ResetErrors();
if($graph == "DEFAULT"){
$q = 'LOAD <'.$urldata.'>';
}else{
$q = 'LOAD <'.$urldata.'> INTO GRAPH <'.$graph.'>';
}
$res = $endpoint->queryUpdate($q);
$err = $endpoint->getErrors();
if ($err) {
print_r($err);
$success = false;
$endpoint->ResetErrors();
}
}
}