public function testFormatSQLStatement()
 {
     $instance = new DebugOutputFormatter();
     $sql = '';
     $alias = '';
     $this->assertInternalType('string', $instance->doFormatSQLStatement($sql, $alias));
 }
Esempio n. 2
0
 private function doExecuteDebugQueryResult($qobj, $sqlOptions, &$entries)
 {
     if (!isset($qobj->joinfield) || $qobj->joinfield === '') {
         return $entries['SQL Query'] = 'Empty result, no SQL query created.';
     }
     $db = $this->store->getConnection('mw.db.queryengine');
     list($startOpts, $useIndex, $tailOpts) = $db->makeSelectOptions($sqlOptions);
     $sql = "SELECT DISTINCT " . "{$qobj->alias}.smw_id AS id," . "{$qobj->alias}.smw_title AS t," . "{$qobj->alias}.smw_namespace AS ns," . "{$qobj->alias}.smw_iw AS iw," . "{$qobj->alias}.smw_subobject AS so," . "{$qobj->alias}.smw_sortkey AS sortkey " . "FROM " . $db->tableName($qobj->joinTable) . " AS {$qobj->alias}" . $qobj->from . ($qobj->where === '' ? '' : ' WHERE ') . $qobj->where . "{$tailOpts} {$startOpts} {$useIndex} " . "LIMIT " . $sqlOptions['LIMIT'] . ' ' . "OFFSET " . $sqlOptions['OFFSET'];
     $res = $db->query('EXPLAIN ' . $sql, __METHOD__);
     $entries['SQL Explain'] = QueryDebugOutputFormatter::doFormatSQLExplainOutput($db->getType(), $res);
     $entries['SQL Query'] = QueryDebugOutputFormatter::doFormatSQLStatement($sql, $qobj->alias);
     $db->freeResult($res);
 }