Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Article extends Entity
- {
- // empty
- // but will auto populated by Table object.
- // there 2 options available to know what attributes that we need to $this->set()
- // 1. Go to the table at database, 2. Go to view template that consumes entity object attributes
- }
- // It's better , because we know what attributes to set IF we change data source
- class Article extends Entity
- {
- private $title;
- private $viewer;
- private $date;
- private $content;
- public function setTitle($title)
- {
- $this->title = $title;
- }
- public function setViewer($viewer)
- {
- $this->viewer = $viewer;
- }
- public function setDate($date)
- {
- $this->date = $date;
- }
- public function setContent($content)
- {
- $this->content = $content;
- }
- }
- $from_redis = $redis->get('somekey');
- $data = json_decode($from_redis, true);
- $article = new Article();
- $article->setTitle($data['title_from_redis']);
- $article->setViewer($data['viewer_from_redis']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement