/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $this->db = static::$dbo; $this->instance = new RelationDataMapper('flower', 'ww_flower'); $this->instance->addTable('category', 'ww_categories', 'flower.catid = category.id'); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); $this->db = static::$dbo; $this->object = new RelationDataMapper('cont', 'ww_content'); $this->object->addTable('cat', 'ww_categories', 'cont.catid = cat.id', 'LEFT')->addTable('user', 'ww_users', 'cont.created_by = user.id', 'LEFT'); }
/** * getLastPost * * @param int $pk * * @return Data */ public function getLastPost($pk) { $mapper = new RelationDataMapper('post', Table::POSTS); $mapper->addTable('topic', Table::TOPICS, 'topic.id = post.topic_id')->addTable('category', LunaTable::CATEGORIES, 'category.id = topic.category_id')->addTable('user', WarderTable::USERS, 'user.id = post.user_id'); $post = $mapper->findOne(array('category.id' => $pk), 'post.created DESC'); return $post; }