public function testFormatDebugOutputWithQuery()
 {
     $description = $this->getMockForAbstractClass('\\SMWDescription');
     $instance = new QueryOutputFormatter();
     $this->assertInternalType('string', $instance->formatDebugOutput('foo', array(), new Query($description)));
 }
Example #2
0
 /**
  * Using a preprocessed internal query description referenced by $rootid, compute
  * the proper debug output for the given query.
  *
  * @param Query $query
  * @param integer $rootid
  *
  * @return string
  */
 private function getDebugQueryResult(Query $query, $rootid)
 {
     $qobj = $this->querySegments[$rootid];
     $db = $this->store->getConnection();
     $entries = array();
     $sql_options = $this->getSQLOptions($query, $rootid);
     list($startOpts, $useIndex, $tailOpts) = $db->makeSelectOptions($sql_options);
     if ($qobj->joinfield !== '') {
         $entries['SQL Query'] = "<tt>SELECT DISTINCT {$qobj->alias}.smw_title AS t,{$qobj->alias}.smw_namespace AS ns FROM " . $db->tableName($qobj->joinTable) . " AS {$qobj->alias}" . $qobj->from . ($qobj->where === '' ? '' : ' WHERE ') . $qobj->where . "{$tailOpts} LIMIT " . $sql_options['LIMIT'] . ' OFFSET ' . $sql_options['OFFSET'] . ';</tt>';
     } else {
         $entries['SQL Query'] = 'Empty result, no SQL query created.';
     }
     $auxtables = '';
     foreach ($this->querySegmentListResolver->getListOfResolvedQueries() as $table => $log) {
         $auxtables .= "<li>Temporary table {$table}";
         foreach ($log as $q) {
             $auxtables .= "<br />&#160;&#160;<tt>{$q}</tt>";
         }
         $auxtables .= '</li>';
     }
     if ($auxtables) {
         $entries['Auxilliary Tables Used'] = "<ul>{$auxtables}</ul>";
     } else {
         $entries['Auxilliary Tables Used'] = 'No auxilliary tables used.';
     }
     return QueryOutputFormatter::formatDebugOutput('SQLStore', $entries, $query);
 }
Example #3
0
 /**
  * Get the output string for a query in debugging mode.
  *
  * @param Query $query
  *
  * @return string
  */
 public function getDebugQueryResult(Query $query)
 {
     $this->sortkeys = $query->sortkeys;
     $sparqlCondition = $this->compoundConditionBuilder->setSortKeys($this->sortkeys)->buildCondition($query->getDescription());
     $entries = array();
     if ($sparqlCondition instanceof SingletonCondition) {
         if ($sparqlCondition->condition === '') {
             // all URIs exist, no querying
             $sparql = 'None (no conditions).';
         } else {
             $condition = $this->compoundConditionBuilder->convertConditionToString($sparqlCondition);
             $namespaces = $sparqlCondition->namespaces;
             $sparql = $this->connection->getSparqlForAsk($condition, $namespaces);
         }
     } elseif ($sparqlCondition instanceof FalseCondition) {
         $sparql = 'None (conditions can not be satisfied by anything).';
     } else {
         $condition = $this->compoundConditionBuilder->convertConditionToString($sparqlCondition);
         $namespaces = $sparqlCondition->namespaces;
         $options = $this->getOptions($query, $sparqlCondition);
         $options['DISTINCT'] = true;
         $sparql = $this->connection->getSparqlForSelect('?' . self::RESULT_VARIABLE, $condition, $options, $namespaces);
     }
     $sparql = str_replace(array('[', ':', ' '), array('&#x005B;', '&#x003A;', '&#x0020;'), $sparql);
     $entries['SPARQL Query'] = "<pre>{$sparql}</pre>";
     return QueryOutputFormatter::formatDebugOutput('SPARQLStore', $entries, $query);
 }