/** * Returns an attribute information hash. * * @param integer $attribute_id An attribute ID. * * @return array The attribute hash. * @throws Whups_Exception */ public function getAttributeDesc($attribute_id) { try { $attribute = $this->_db->selectOne('SELECT attribute_name, attribute_description, ' . 'attribute_type, attribute_params, attribute_required ' . 'FROM whups_attributes_desc WHERE attribute_id = ?', array((int) $attribute_id)); } catch (Horde_Db_Exception $e) { throw new Whups_Exception($e); } return array('id' => $attribute_id, 'name' => $this->_fromBackend($attribute['attribute_name']), 'description' => $this->_fromBackend($attribute['attribute_description']), 'type' => empty($attribute['attribute_type']) ? 'text' : $attribute['attribute_type'], 'params' => $this->_fromBackend(@unserialize($attribute['attribute_params'])), 'required' => (bool) $attribute['attribute_required']); }
/** * Reads the previously written sync anchors from the database. * * @param string $databaseURI URI of database to sync. Like calendar, * tasks, contacts or notes. May include * optional parameters: * tasks?options=ignorecompleted. * * @return mixed Two-element array with client anchor and server anchor as * stored in previous writeSyncAnchor() calls. False if no * data found. */ public function readSyncAnchors($databaseURI) { $database = $this->normalize($databaseURI); $query = 'SELECT syncml_clientanchor, syncml_serveranchor ' . 'FROM horde_syncml_anchors ' . 'WHERE syncml_syncpartner = ? AND syncml_db = ? AND ' . 'syncml_uid = ?'; $values = array($this->_syncDeviceID, $database, $this->_user); try { if ($res = $this->_db->selectOne($query, $values)) { return array($res['syncml_clientanchor'], $res['syncml_serveranchor']); } } catch (Horde_Db_Exception $e) { } return false; }
/** * Return a station object matching $code. * * @param string $code The ICAO station identifier. * * @return Horde_Service_Weather_Station The station object. * @throws Horde_Service_Weather_Exception * @throws Horde_Exception_NotFound */ protected function _getStation($code) { if (empty($this->_db)) { return new Horde_Service_Weather_Station(array('code' => $code, 'name' => $code)); } $sql = 'SELECT icao, name, country, latitude, longitude from ' . $this->_tableName . ' WHERE icao = ?'; try { $result = $this->_db->selectOne($sql, array($code)); } catch (Horde_Db_Exception $e) { throw new Horde_Service_Weather_Exception($e); } if (empty($result)) { throw new Horde_Exception_NotFound(); } return new Horde_Service_Weather_Station(array('name' => $result['name'], 'code' => $code, 'country_name' => $result['country'], 'lat' => $result['latitude'], 'lon' => $result['lon'])); }
/** * Retrieve a story from storage. * * @param integer $story_id They story id. * @param boolean $read Increment the read counter? * * @return The story array. * @throws Horde_Exception_NotFound * @throws Jonah_Exception * */ protected function _getStory($story_id, $read = false) { $sql = 'SELECT stories.story_id as id, ' . 'stories.channel_id, ' . 'stories.story_author AS author, ' . 'stories.story_title AS title, ' . 'stories.story_desc AS description, ' . 'stories.story_body_type AS body_type, ' . 'stories.story_body AS body, ' . 'stories.story_url AS url, ' . 'stories.story_permalink AS permalink, ' . 'stories.story_published AS published, ' . 'stories.story_updated AS updated, ' . 'stories.story_read AS readcount ' . 'FROM jonah_stories AS stories WHERE stories.story_id=?'; Horde::log('SQL Query by Jonah_Driver_sql::_getStory(): ' . $sql, 'DEBUG'); try { $result = $this->_db->selectOne($sql, array((int) $story_id)); } catch (Horde_Db_Exception $e) { Horde::log($e->getMessage(), 'ERR'); throw new Jonah_Exception($e); } if (empty($result)) { throw new Horde_Exception_NotFound(sprintf(_("Story id \"%s\" not found."), $story_id)); } $result['tags'] = $GLOBALS['injector']->getInstance('Jonah_Tagger')->getTags($story_id, Jonah_Tagger::TYPE_STORY); $result = $this->_convertFromBackend($result); if ($read) { $this->_readStory($story_id); } return $result; }