public function rightJoin($key, DatabaseRecordContainer $container) { $newRecords = array(); $_this = $this; $container->foreachRecords(function (DatabaseRecord $record1) use($_this, &$newRecords, $key) { $foundMatch = false; $_this->foreachRecords(function (DatabaseRecord $record2) use($record1, &$newRecords, $key, &$foundMatch) { if ($record1[$key] == $record2[$key]) { $foundMatch = true; $newRecords[] = new MixedRecord($record1->setAll($record2->getAll())->getAll()); } }); if (!$foundMatch) { $row = array_fill_keys(array_merge(array_keys($record1->getAll()), array_keys($_this[0]->getAll())), null); $newRecord = new MixedRecord($row); $newRecords[] = $newRecord->setAll($record1->getAll()); } }); return new DatabaseRecordContainer($newRecords); }
/** * @throws \PandaBase\Exception\RecordValueNotExists */ public function testSetValuesWithException() { $mixedRecord = new MixedRecord(array("test_key" => "test_value")); $this->assertEquals("test_value", $mixedRecord->get("test_key")); $this->assertEquals("test_value", $mixedRecord["test_key"]); }