private function compileAccordingConditionsAndHackThemIntoQobj(array $extraProperties, $qobj, $qid) { $this->queryBuilder->setSortKeys($this->sortKeys); $this->queryBuilder->buildQuerySegmentFor(new Conjunction($extraProperties)); $newQuerySegmentId = $this->queryBuilder->getLastQuerySegmentId(); $this->querySegments = $this->queryBuilder->getQuerySegments(); $this->errors = $this->queryBuilder->getErrors(); $newQuerySegment = $this->querySegments[$newQuerySegmentId]; // This is always an QuerySegment::Q_CONJUNCTION ... foreach ($newQuerySegment->components as $cid => $field) { // ... so just re-wire its dependencies $qobj->components[$cid] = $qobj->joinfield; $qobj->sortfields = array_merge($qobj->sortfields, $this->querySegments[$cid]->sortfields); } $this->querySegments[$qid] = $qobj; }
public function testWhenSomeQuerySegments_getQuerySegmentsReturnsThemAll() { $instance = new QueryBuilder($this->store); $firstQuerySegment = new QuerySegment(); $secondQuerySegment = new QuerySegment(); $instance->addQuerySegmentForId(42, $firstQuerySegment); $instance->addQuerySegmentForId(23, $secondQuerySegment); $this->assertSame(array(42 => $firstQuerySegment, 23 => $secondQuerySegment), $instance->getQuerySegments()); }