/** * * @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; }
/** * * @param type $id * @return type */ public static function fetchPhotosByDogId($id) { $query = App_Model_Photo::getQuery(array('ph.*'))->join('tb_dogphoto', 'ph.id = dp.photoId', 'dp', array('dp.dogId', 'dp.photoId'))->join('tb_dog', 'dp.dogId = do.id', 'do', array('do.id' => 'dogId'))->where('do.id = ?', (int) $id); $photos = App_Model_Photo::initialize($query); return $photos; }