예제 #1
0
 /**
  * Implementation of SMWStore::getInProperties(). This function is meant to
  * be used for finding properties that link to wiki pages.
  * @todo When used for other datatypes, the function may return too many
  * properties since it selects results by comparing the stored information
  * (DB keys) only, while not currently comparing the type of the returned
  * property to the type of the queried data. So values with the same DB keys
  * can be confused. This is a minor issue now since no code is known to use
  * this function in cases where this occurs.
  */
 public function getInProperties(SMWDataValue $value, $requestoptions = null)
 {
     wfProfileIn("SMWSQLStoreLight::getInProperties (SMW)");
     $db = wfGetDB(DB_SLAVE);
     $result = array();
     $typeid = $value->getTypeID();
     if ($requestoptions !== null) {
         // potentially need to get more results, since options apply to union
         $suboptions = clone $requestoptions;
         $suboptions->limit = $requestoptions->limit + $requestoptions->offset;
         $suboptions->offset = 0;
     } else {
         $suboptions = null;
     }
     foreach (array('smwsimple_data', 'smwsimple_special') as $tablename) {
         if (SMWSQLStoreLight::findTypeTableName($typeid) != $tablename) {
             continue;
         }
         $valuestring = $tablename == 'smwsimple_special' ? reset($value->getDBkeys()) : serialize($value->getDBkeys());
         $where = 'value=' . $db->addQuotes($valuestring);
         $res = $db->select($tablename, 'DISTINCT propname', $where . $this->getSQLConditions($suboptions, 'propname', 'propname'), 'SMW::getInProperties', $this->getSQLOptions($suboptions, 'propname'));
         foreach ($res as $row) {
             $result[] = new SMWDIProperty($row->propname);
         }
         $db->freeResult($res);
     }
     $result = $this->applyRequestOptions($result, $requestoptions);
     // apply options to overall result
     wfProfileOut("SMWSQLStoreLight::getInProperties (SMW)");
     return $result;
 }