_db->find($data['id']); if (count($result)) { $data['created_time'] = $result->current()->created_time; $now = new Zend_Date; if (isset($data['lease_seconds'])) { $data['expiration_time'] = $now->add($data['lease_seconds'], Zend_Date::SECOND) ->get('yyyy-MM-dd HH:mm:ss'); } $this->_db->update( $data, $this->_db->getAdapter()->quoteInto('id = ?', $data['id']) ); return false; } $this->_db->insert($data); return true; } /** * Get subscription by ID/key * * @param string $key * @throws Zend_Db_Table_Exception * @throws Zend_Feed_Pubsubhubbub_Exception * @return array */ public function getSubscription($key) { if (empty($key) || !is_string($key)) { require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "key"' .' of "' . $key . '" must be a non-empty string'); } $result = $this->_db->find($key); if (count($result)) { return $result->current()->toArray(); } return false; } /** * Determine if a subscription matching the key exists * * @param string $key * @throws Zend_Db_Table_Exception * @throws Zend_Feed_Pubsubhubbub_Exception * @return bool */ public function hasSubscription($key) { if (empty($key) || !is_string($key)) { require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "key"' .' of "' . $key . '" must be a non-empty string'); } $result = $this->_db->find($key); if (count($result)) { return true; } return false; } /** * Delete a subscription * * @param string $key * @return bool */ public function deleteSubscription($key) { $result = $this->_db->find($key); if (count($result)) { $this->_db->delete( $this->_db->getAdapter()->quoteInto('id = ?', $key) ); return true; } return false; } }