/** * * @return \App_Model_Dog */ public function getDogById() { $query = App_Model_Exam::getQuery(array('ex.*'))->join('tb_dogexam', 'ex.id = de.examId', 'de', array('de.dogId', 'de.examId'))->where('de.dogId = ?', (int) $this->getId()); $this->_exams = App_Model_Exam::initialize($query); $query2 = App_Model_Photo::getQuery(array('ph.*'))->join('tb_dogphoto', 'ph.id = dp.photoId', 'dp', array('dp.dogId', 'dp.photoId'))->where('dp.dogId = ?', (int) $this->getId()); $this->_adPhoto = App_Model_Photo::initialize($query2); return $this; }