/** * Get feed by resource. * * @param array $typeArray * @param MIDAS_GlobalDao $dao * @return array * @throws Zend_Exception */ public function getFeedByResourceAndType($typeArray, $dao) { if (!is_array($typeArray)) { $typeArray = array($typeArray); } $sql = $this->database->select()->setIntegrityCheck(false)->from(array('p' => 'feed'))->where('resource = ?', (string) $dao->getKey()); $rowset = $this->database->fetchAll($sql); $feeds = array(); foreach ($rowset as $row) { $feed = $this->initDao('Feed', $row); if (in_array($feed->getType(), $typeArray)) { $feeds[] = $this->initDao('Feed', $row); } } return $feeds; }
/** * Delete from the database. * * @param MIDAS_GlobalDao $dao * @return true * @throws Zend_Exception */ public function delete($dao) { if (!$dao->saved) { throw new Zend_Exception('The dao should be saved first ...'); } if (!isset($this->_key) || !$this->_key) { $query = array(); foreach ($this->_mainData as $name => $option) { if ($option['type'] == MIDAS_DATA) { $query[$name . ' = ?'] = $dao->{$name}; } } if (empty($query)) { throw new Zend_Exception('Huge error, you almost deleted everything'); } parent::delete($query); $dao->saved = false; return true; } $key = $dao->getKey(); if (!isset($key)) { throw new Zend_Exception('Unable to find the key'); } parent::delete(array($this->_key . ' = ?' => $dao->getKey())); $key = $dao->_key; $dao->set($key, null); $dao->saved = false; return true; }