phpsparqlconstructarc2

How to count number of triplets in ARC2 PHP


I created a CONSTRUCT query in ARC2 PHP, but how is it possible to count how many triplets I have received?

$query = '
  PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

   CONSTRUCT { ?c rdfs:label ?name }
 WHERE {
   ?c rdf:type dbpedia-owl:City. 
   ?c rdfs:label ?name .
   ?c dbpedia-owl:country <http://dbpedia.org/resource/Italy> .
   OPTIONAL { ?c dbpedia-owl:areaCode ?areacode }
   FILTER ( lang(?name) = "it")
 }';

Because right now the query doesn't write any output.


Solution

  • SELECT (COUNT(*) as ?cnt) WHERE { ?s ?p ?o }