/** * @since 2.3 * * @param array $idList * * @return DIWikiPage[] */ public function getDataItemPoolHashListFor(array $idList) { $rows = $this->connection->select(\SMWSQLStore3::ID_TABLE, array('smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject'), array('smw_id' => $idList), __METHOD__); $dataItemPoolHashList = array(); foreach ($rows as $row) { $dataItemPoolHashList[] = HashBuilder::createHashIdFromSegments($row->smw_title, $row->smw_namespace, $row->smw_iw, $row->smw_subobject); } return $dataItemPoolHashList; }
/** * @since 2.3 * * @param array $idList * * @return DIWikiPage[] */ public function getDataItemPoolHashListFor(array $idList) { $rows = $this->connection->select(\SMWSQLStore3::ID_TABLE, array('smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject'), array('smw_id' => $idList), __METHOD__); $resultIterator = $this->iteratorFactory->newResultIterator($rows); $mappingIterator = $this->iteratorFactory->newMappingIterator($resultIterator, function ($row) { return HashBuilder::createHashIdFromSegments($row->smw_title, $row->smw_namespace, $row->smw_iw, $row->smw_subobject); }); return $mappingIterator; }
private function doRebuildByPropertyTable($proptable) { $searchTable = $this->getSearchTable(); if ($proptable->getDiType() === DataItem::TYPE_URI) { $fetchFields = array('s_id', 'p_id', 'o_blob', 'o_serialized'); } else { $fetchFields = array('s_id', 'p_id', 'o_blob', 'o_hash'); } $table = $proptable->getName(); $pid = ''; // Fixed tables don't have a p_id column therefore get it // from the ID TABLE if ($proptable->isFixedPropertyTable()) { unset($fetchFields[1]); // p_id $pid = $searchTable->getPropertyIdBy(new DIProperty($proptable->getFixedProperty())); if ($searchTable->isExemptedPropertyById($pid)) { return $this->skippedTables[$table] = 'Fixed property table that belongs to the ' . $proptable->getFixedProperty() . ' exempted property.'; } } $rows = $this->connection->select($table, $fetchFields, array(), __METHOD__); if ($rows === false || $rows === null) { return $this->skippedTables[$table] = 'Empty table.'; } $this->doRebuildFromRows($searchTable, $table, $pid, $rows); }
/** * @since 1.9.2 * * @param int $startId * @param int $endId * * @return Title[] * @throws RuntimeException */ public function selectByIdRange($startId = 0, $endId = 0) { if ($this->namespace === null) { throw new RuntimeException('Unrestricted selection without a namespace is not supported'); } if ($this->namespace === NS_CATEGORY) { $tableName = 'category'; $fields = array('cat_title', 'cat_id'); $conditions = array("cat_id BETWEEN {$startId} AND {$endId}"); $options = array('ORDER BY' => 'cat_id ASC', 'USE INDEX' => 'cat_title'); } else { $tableName = 'page'; $fields = array('page_namespace', 'page_title', 'page_id'); $conditions = array("page_id BETWEEN {$startId} AND {$endId}") + array('page_namespace' => $this->namespace); $options = array('ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY'); } $res = $this->connection->select($tableName, $fields, $conditions, __METHOD__, $options); return $this->makeTitlesFromSelection($res); }
public function testSelectThrowsException() { $database = $this->getMockBuilder('\\DatabaseBase')->disableOriginalConstructor()->setMethods(array('select'))->getMockForAbstractClass(); $database->expects($this->once())->method('select'); $connectionProvider = $this->getMockBuilder('\\SMW\\DBConnectionProvider')->disableOriginalConstructor()->getMock(); $connectionProvider->expects($this->atLeastOnce())->method('getConnection')->will($this->returnValue($database)); $instance = new Database($connectionProvider); $this->setExpectedException('RuntimeException'); $this->assertInstanceOf('ResultWrapper', $instance->select('Foo', 'Bar', '', __METHOD__)); }