/** * adds record's data to cache * @param AbstractRecord $record */ protected function addToCache($data) { try { if (is_bool(AbstractRecord::$isCacheOnTempSwitch) && !AbstractRecord::$isCacheOnTempSwitch) { return; } if (!$this->isCacheOn()) { return; } //var_dump("pridavam do cache ". $this->getCacheFileName() . " $id"); $itemType = $this->getClassVar("itemType"); $idColName = eval("return {$itemType}::\$idColName;"); $id = $this->cacheLastKeyStored + 1; LBoxCacheAbstractRecord::getInstance($this->getTableName(), $this->getSQL(), self::getCacheGroup())->{$id} = $data; $this->isCacheSynchronized = false; $this->cacheLastKeyStored++; } catch (Exception $e) { throw $e; } }
/** * Check if table has tree structure * @return bool * @throws Exception */ protected function isTree() { try { $className = get_class($this); if (array_key_exists($className, self::$isTree) && is_bool(self::$isTree[$className])) { return self::$isTree[$className]; } if ($this->isInCache()) { $data = LBoxCacheAbstractRecord::getInstance($this->getClassVar("tableName"), $this->params[$this->getClassVar("idColName")], self::getCacheGroup())->getData(); if (is_numeric($cacheValue = $data["systemrecord_istree"])) { return self::$isTree[$className] = (bool) $cacheValue; } } $columns = $this->getClassVar("treeColNames"); $tableName = $this->getClassVar("tableName"); try { $this->getDb()->initiateQuery($this->getQueryBuilder()->getSelectColumns($tableName, $columns, new QueryBuilderWhere(), array(1))); } catch (DbControlException $e) { // throw $e; // column does not found - table is not tree self::$isTree[$className] = false; return self::$isTree[$className]; break; } self::$isTree[$className] = true; return self::$isTree[$className]; } catch (Exception $e) { throw $e; } }