Пример #1
0
 public function testSetValues()
 {
     $mixedRecord = new MixedRecord(array("test_key_1" => "test1", "test_key_2" => "test2"));
     $mixedRecord["test_key_1"] = "test_value_1";
     $this->assertEquals("test_value_1", $mixedRecord["test_key_1"]);
     $mixedRecord->set("test_key_2", "test_value_2");
     $this->assertEquals("test_value_2", $mixedRecord["test_key_2"]);
     $mixedRecord->setAll(array("test_key_1" => "test1All", "test_key_2" => "test2All"));
     $this->assertEquals(array("test_key_1" => "test1All", "test_key_2" => "test2All"), $mixedRecord->getAll());
 }
 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);
 }