model = $model; } public function getId() { return $this->id; } public function setId($id) { $this->id = $id; } public function getCache($key) { return isset($this->__cache[$key]) ? $this->__cache[$key] : null; } public function setCache($key, $value) { $this->__cache[$key] = $value; } public function removeCache($key) { unset($this->__cache[$key]); } public function resetCache() { $this->__cache = []; } public function hasCache($key) { return isset($this->__cache[$key]); } protected function getColumnWithCache($columnName) { if ($this->hasCache($columnName)) return $this->getCache($columnName); $stmt = \Chibi\Sql\Statements::select(); $stmt->setTable($this->model->getTableName()); $stmt->setColumn($columnName); $stmt->setCriterion(\Chibi\Sql\Functors::equals('id', new \Chibi\Sql\Binding($this->getId()))); $value = Core::getDatabase()->fetchOne($stmt)[$columnName]; $this->setCache($columnName, $value); return $value; } }