Example #1
0
 function CONSTRUCT($query, $base_uri = null)
 {
     if (is_null($base_uri)) {
         $base_uri = $this->_base_uri;
     }
     timings($query);
     $q = librdf_new_query($this->_world, 'sparql', null, $query, $base_uri);
     $r = librdf_model_query_execute($this->_model, $q);
     $r_stream = librdf_query_results_as_stream($r);
     $r_store = librdf_new_storage($this->_world, 'memory', '', null);
     $r_model = librdf_new_model($this->_world, $r_store, null);
     librdf_model_add_statements($r_model, $r_stream);
     librdf_free_stream($r_stream);
     $serializer = librdf_new_serializer($this->_world, 'json', null, null);
     $r = librdf_serializer_serialize_model_to_string($serializer, null, $r_model);
     librdf_free_serializer($serializer);
     $r = json_decode($r, 1);
     if (is_null($r)) {
         $r = array();
     }
     librdf_free_model($r_model);
     librdf_free_storage($r_store);
     librdf_free_query($q);
     timings();
     return $r;
 }
Example #2
0
 /**
  * Free the query resources.
  *
  * @return  void
  * @access  public
  */
 public function __destruct()
 {
     if ($this->query) {
         librdf_free_query($this->query);
     }
 }