예제 #1
0
 public function testBindIterator()
 {
     $anydata = new \ByJG\AnyDataset\Repository\AnyDataset();
     $sr = new \ByJG\AnyDataset\Repository\SingleRow();
     $sr->addField("id", 10);
     $sr->addField("name", "Testing");
     $anydata->appendRow($sr);
     $object = new \AnyDataSet\Tests\Sample\SampleModel($anydata->getIterator()->moveNext()->toArray());
     $this->assertEquals(10, $object->Id);
     $this->assertEquals("Testing", $object->getName());
 }
예제 #2
0
 /**
  *
  * @param type $field
  * @param type $value
  * @return \ByJG\AnyDataset\Repository\SingleRow
  */
 public static function getInfoLocaleDB($field, $value)
 {
     if (self::$_localeData == null) {
         $file = new \Xmlnuke\Core\Processor\AnydatasetSetupFilenameProcessor('locale');
         self::$_localeData = new \ByJG\AnyDataset\Repository\AnyDataset($file->FullQualifiedNameAndPath());
     }
     if (!isset(self::$_localeDbCache[$field])) {
         $filter = new \ByJG\AnyDataset\Repository\IteratorFilter();
         $filter->addRelation($field, \ByJG\AnyDataset\Enum\Relation::CONTAINS, $value);
         $it = self::$_localeData->getIterator($filter);
         if ($it->hasNext()) {
             self::$_localeDbCache[$field] = $it->moveNext();
         } else {
             $sr = new \ByJG\AnyDataset\Repository\SingleRow();
             \Xmlnuke\Core\Engine\Context::getInstance()->WriteWarningMessage("The language {$value} was not found in locale.anydata.xml file");
             $sr->AddField('name', $value . ' ???');
             $sr->AddField('shortname', $value);
             self::$_localeDbCache[$field] = $sr;
         }
     }
     return self::$_localeDbCache[$field];
 }