/** * {@inheritdoc} */ private function buildQuery(PrototypeInterface $prototype) { /** * Need to get all hmtb id's that are stored locally. */ $hmtbFieldId = $prototype->getFieldByName('hmtb-id')->getId(); $sql = "SELECT v.stringValue\n FROM accard_sample_proto_fldval AS v\n LEFT JOIN accard_sample AS a ON (v.sampleId = a.id)\n WHERE v.fieldId IN (%s)"; return sprintf($sql, $hmtbFieldId); }
/** * Prepare Local Results */ private function prepareResults(array $results, PrototypeInterface $prototype) { $localResults = array(); foreach ($results as $key => $result) { $result = array_change_key_case($result, CASE_LOWER); $sampleId = $result['sampleid']; $fieldId = $result['fieldid']; if (!isset($localResults[$sampleId])) { $localResults[$sampleId] = array(); } $localResults[$sampleId][$fieldId] = $result['stringvalue']; unset($results[$key]); } unset($results); $fields = array($prototype->getFieldByName('genetic-results-cpd-id'), $prototype->getFieldByName('genetic-results-gene-id'), $prototype->getFieldByName('genetic-results-transcript-id'), $prototype->getFieldByName('genetic-results-position'), $prototype->getFieldByName('genetic-results-genotype'), $prototype->getFieldByName('genetic-results-fdp'), $prototype->getFieldByName('genetic-results-frd'), $prototype->getFieldByName('genetic-results-fad'), $prototype->getFieldByName('genetic-results-faf')); // Turn this into an array like; // array('MyConcatIdForComparison', 'SomeOtherCocatenation'); $concatenatedLocalRecords = $this->compileLocalRecords($localResults, $fields); return $concatenatedLocalRecords; }