public function __construct(DataStoresInterface $cachingDbTable, $cdsId) { $this->cachingDbTable = $cachingDbTable; $query = new Query(); $query->setQuery(new EqNode($this->cdsIdentifierString, $cdsId)); $this->items = $this->cachingDbTable->query($query); foreach ($this->items as &$item) { $item[$this->cachingDbTable->getIdentifier()] = $item[$this->dataIdentifierString]; unset($item[$this->dataIdentifierString]); unset($item[$this->cdsIdentifierString]); $item = array_filter($item); foreach ($item as $key => $value) { switch ($key) { case in_array($key, $this->fieldType['int']): if (is_numeric($value)) { $item[$key] = (int) $value; } else { throw new \Exception('Can\'t parse to int value:' . $value . 'from field: ' . $key); } break; case in_array($key, $this->fieldType['float']): if (is_numeric($value)) { $item[$key] = (double) $value; } else { throw new \Exception('Can\'t parse to float value:' . $value . 'from field: ' . $key); } break; case in_array($key, $this->fieldType['string']): $item[$key] = (string) $value; break; default: throw new \Exception('Type not set for field: ' . $key); } } } parent::__construct(); }
/** * Return primary key * * Return "id" by default * * @see DEF_ID * @return string "id" by default */ public function getIdentifier() { return $this->cashStore->getIdentifier(); }
/** * {@inheritdoc} * * {@inheritdoc} */ public function getIdentifier() { $this->preGetIdentifier(); $result = $this->dataStore->getIdentifier(); return $this->postGetIdentifier($result); }