예제 #1
0
 /**
  * Returns wanted properties
  *
  * @note This function is very resource intensive and needs to be cached on
  * medium/large wikis.
  *
  * @since 1.9
  *
  * @return DIProperty[]
  */
 protected function doQuery()
 {
     Profiler::In(__METHOD__);
     $options = $this->store->getSQLOptions($this->requestOptions, 'title');
     $options['ORDER BY'] = 'count DESC';
     // TODO: this is not how JOINS should be specified in the select function
     $res = $this->dbConnection->select($this->dbConnection->tableName($this->propertyTable->getName()) . ' INNER JOIN ' . $this->dbConnection->tableName($this->store->getObjectIds()->getIdTable()) . ' ON p_id=smw_id LEFT JOIN ' . $this->dbConnection->tableName('page') . ' ON (page_namespace=' . $this->dbConnection->addQuotes(SMW_NS_PROPERTY) . ' AND page_title=smw_title)', 'smw_title, COUNT(*) as count', 'smw_id > 50 AND page_id IS NULL GROUP BY smw_title', __METHOD__, $options);
     Profiler::Out(__METHOD__);
     return $res;
 }
 private function selectPropertiesFromTable($propertyTable)
 {
     $options = $this->store->getSQLOptions($this->requestOptions, 'title');
     $idTable = \SMWSQLStore3::ID_TABLE;
     $options['ORDER BY'] = 'count DESC';
     $options['GROUP BY'] = 'smw_title';
     $conditions = array('smw_id > ' . \SMWSql3SmwIds::FXD_PROP_BORDER_ID, 'page_id IS NULL');
     $db = $this->store->getConnection('mw.db');
     $res = $db->select(array($idTable, 'page', $propertyTable->getName()), array('smw_title', 'COUNT(*) as count'), $conditions, __METHOD__, $options, array($idTable => array('INNER JOIN', 'p_id=smw_id'), 'page' => array('LEFT JOIN', array('page_namespace=' . $db->addQuotes(SMW_NS_PROPERTY), 'page_title=smw_title'))));
     return $res;
 }