delete() public method

Executes the delete statement and returns the number of rows affected.
public delete ( string $sql, mixed $arg1 = null, string $arg2 = null ) : integer
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return integer Number of rows affected.
Esempio n. 1
0
File: Db.php Progetto: horde/horde
 public function getMany($num = 50)
 {
     $tasks = array();
     $values = array();
     $query = 'SELECT * FROM horde_queue_tasks where task_queue = ? ORDER BY task_id LIMIT ?';
     $values[] = $this->_queue;
     $values[] = $num;
     try {
         $rows = $this->_db->select($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Queue_Exception($e);
     }
     $query = 'DELETE FROM horde_queue_tasks WHERE task_id = ?';
     foreach ($rows as $row) {
         $tasks[] = unserialize($row['task_fields']);
         // TODO: Evaluate if a single call for all IDs is faster for
         // various scenarios
         try {
             $this->_db->delete($query, array($row['task_id']));
         } catch (Horde_Db_Exception $e) {
             throw new Horde_Queue_Exception($e);
         }
     }
     return $tasks;
 }
Esempio n. 2
0
File: Sql.php Progetto: horde/horde
 /**
  * Delete all expired connection IDs.
  *
  * @throws Horde_Token_Exception
  */
 public function purge()
 {
     /* Build SQL query. */
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE token_timestamp < ?';
     $values = array(time() - $this->_params['timeout']);
     /* Return an error if the update fails. */
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Token_Exception($e);
     }
 }
Esempio n. 3
0
 /**
  * Reset the sync state for this device, for the specified collection.
  *
  * @param string $id  The collection to reset.
  *
  * @return void
  * @throws Horde_ActiveSync_Exception
  */
 protected function _resetDeviceState($id)
 {
     $this->_logger->info(sprintf('[%s] Resetting device state for device: %s, user: %s, and collection: %s.', $this->_procid, $this->_deviceInfo->id, $this->_deviceInfo->user, $id));
     $state_query = 'DELETE FROM ' . $this->_syncStateTable . ' WHERE sync_devid = ? AND sync_folderid = ? AND sync_user = ?';
     $map_query = 'DELETE FROM ' . $this->_syncMapTable . ' WHERE sync_devid = ? AND sync_folderid = ? AND sync_user = ?';
     $mailmap_query = 'DELETE FROM ' . $this->_syncMailMapTable . ' WHERE sync_devid = ? AND sync_folderid = ? AND sync_user = ?';
     try {
         $this->_db->delete($state_query, array($this->_deviceInfo->id, $id, $this->_deviceInfo->user));
         $this->_db->delete($map_query, array($this->_deviceInfo->id, $id, $this->_deviceInfo->user));
         $this->_db->delete($mailmap_query, array($this->_deviceInfo->id, $id, $this->_deviceInfo->user));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
     // Remove the collection data from the synccache as well.
     $cache = new Horde_ActiveSync_SyncCache($this, $this->_deviceInfo->id, $this->_deviceInfo->user, $this->_logger);
     if ($id != Horde_ActiveSync::REQUEST_TYPE_FOLDERSYNC) {
         $cache->removeCollection($id, false);
     } else {
         $this->_logger->notice(sprintf('[%s] Clearing foldersync state from synccache.', $this->_procid));
         $cache->clearFolders();
         $cache->clearCollections();
         $cache->hierarchy = '0';
     }
     $cache->save();
 }
Esempio n. 4
0
 /**
  * Removes a permission from the permissions system permanently.
  *
  * @param Horde_Perms_Permission_Sql $perm  The permission to
  *                                                remove.
  * @param boolean $force                          Force to remove every
  *                                                child.
  *
  * @return boolean  True if permission was deleted.
  * @throws Horde_Perms_Exception
  */
 public function removePermission(Horde_Perms_Permission $perm, $force = false)
 {
     $name = $perm->getName();
     $this->_cache->expire('perm_sql_' . $this->_cacheVersion . $name);
     $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $name);
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE perm_name = ?';
     try {
         $result = $this->_db->delete($query, array($name));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Perms_Exception($e);
     }
     if (!$force) {
         return (bool) $result;
     }
     /* Need to expire cache for all sub-permissions. */
     try {
         $sub = $this->_db->selectValues('SELECT perm_name FROM ' . $this->_params['table'] . ' WHERE perm_name LIKE ?', array($name . ':%'));
         foreach ($sub as $val) {
             $this->_cache->expire('perm_sql_' . $this->_cacheVersion . $val);
             $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $val);
         }
     } catch (Horde_Db_Exception $e) {
     }
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE perm_name LIKE ?';
     try {
         return (bool) $this->_db->delete($query, array($name . ':%'));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Perms_Exception($e);
     }
 }
Esempio n. 5
0
 /**
  * Deletes all contacts from a specific address book.
  *
  * @param string $sourceName  The source to remove all contacts from.
  *
  * @return array  An array of UIDs
  * @throws Turba_Exception
  */
 protected function _deleteAll($sourceName = null)
 {
     if (!$GLOBALS['registry']->getAuth()) {
         throw new Turba_Exception('Permission denied');
     }
     /* Get owner id */
     $values = empty($sourceName) ? array($GLOBALS['registry']->getAuth()) : array($sourceName);
     if (empty($this->map['__owner'])) {
         throw new Turba_Exception(_("Unable to find __owner field. Cannot delete."));
     }
     $owner_field = $this->map['__owner'];
     /* Need a list of UIDs so we can notify History */
     $query = sprintf('SELECT %s FROM %s WHERE %s = ?', $this->map['__uid'], $this->_params['table'], $owner_field);
     try {
         $ids = $this->_db->selectValues($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Turba_Exception(_("Server error when deleting data."));
     }
     /* Do the deletion */
     $query = sprintf('DELETE FROM %s WHERE %s = ?', $this->_params['table'], $owner_field);
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Turba_Exception(_("Server error when deleting data."));
     }
     return $ids;
 }
Esempio n. 6
0
 /**
  * @TODO
  * @global  $conf
  * @return <type>
  */
 public function purge()
 {
     global $conf;
     $query = 'DELETE FROM hermes_timeslices' . ' WHERE timeslice_exported = ? AND timeslice_date < ?';
     $values = array(1, mktime(0, 0, 0, date('n'), date('j') - $conf['time']['days_to_keep']));
     return $this->_db->delete($query, $values);
 }
Esempio n. 7
0
File: Sql.php Progetto: horde/horde
 /**
  * Deletes an ID map from the backend storage.
  *
  * @param string $external    An external collection ID.
  * @param string $interface  The collection's application.
  *
  * @throws Horde_Dav_Exception
  */
 public function deleteExternalCollectionId($external, $interface)
 {
     try {
         $this->_db->delete('DELETE FROM horde_dav_collections ' . 'WHERE id_external = ? AND id_interface = ?', array($external, $interface));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Dav_Exception($e);
     }
 }
Esempio n. 8
0
 /**
  * Removes a user from a group.
  *
  * @param mixed $gid    A group ID.
  * @param string $user  A user name.
  *
  * @throws Horde_Group_Exception
  */
 public function removeUser($gid, $user)
 {
     try {
         $this->_db->delete('DELETE FROM horde_groups_members WHERE group_uid = ? AND user_uid = ?', array($gid, $user));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Group_Exception($e);
     }
 }
Esempio n. 9
0
 /**
  * Executes the delete statement and returns the number of rows affected.
  *
  * @param string $sql   SQL statement.
  * @param mixed $arg1   Either an array of bound parameters or a query
  *                      name.
  * @param string $arg2  If $arg1 contains bound parameters, the query
  *                      name.
  *
  * @return integer  Number of rows affected.
  * @throws Horde_Db_Exception
  */
 public function delete($sql, $arg1 = null, $arg2 = null)
 {
     $result = $this->_write->delete($sql, $arg1, $arg2);
     $this->_lastQuery = $this->_write->getLastQuery();
     // Once doing writes, keep using the write backend even for reads
     // at least during the same request, to help against stale data.
     $this->_read = $this->_write;
     return $result;
 }
Esempio n. 10
0
 /**
  * Deletes an entry from storage
  *
  * @see Kronolith_Geo_Base#removeLocation()
  *
  * @param string $event_id
  *
  * @throws Kronolith_Exception
  */
 public function deleteLocation($event_id)
 {
     $sql = 'DELETE FROM kronolith_events_geo WHERE event_id = ?';
     try {
         $this->_db->delete($sql, array($event_id));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Exception($e);
     }
 }
Esempio n. 11
0
 /**
  * Deletes an Ansel_Image from data storage.
  *
  * @param integer $image_id  The image id(s) to remove.
  *
  * @throws Ansel_Exception
  */
 public function removeImage($image_id)
 {
     try {
         $this->_db->delete('DELETE FROM ansel_images WHERE image_id = ' . (int) $image_id);
         $this->_db->delete('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int) $image_id);
     } catch (Horde_Db_Exception $e) {
         throw new Ansel_Exception($e);
     }
 }
Esempio n. 12
0
 /**
  */
 public function clear()
 {
     $query = 'DELETE FROM ' . $this->_params['table'];
     try {
         $this->_db->delete($query);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Cache_Exception($e);
     }
 }
Esempio n. 13
0
 /**
  * Increment, and return, the modseq value.
  *
  * @return integer  The new modseq value.
  */
 protected function _nextModSeq()
 {
     try {
         $result = $this->_db->insert('INSERT INTO horde_histories_modseq (history_modseqempty) VALUES(0)');
         $this->_db->delete('DELETE FROM horde_histories_modseq WHERE history_modseq <> ?', array($result));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_History_Exception($e);
     }
     return $result;
 }
Esempio n. 14
0
 /**
  */
 protected function _deleteOldEntries($before)
 {
     /* Build the SQL query. */
     $query = sprintf('DELETE FROM %s WHERE sentmail_ts < ?', $this->_params['table']);
     /* Execute the query. */
     try {
         $this->_db->delete($query, array($before));
     } catch (Horde_Db_Exception $e) {
     }
 }
Esempio n. 15
0
 /**
  * Stores user preferences and default values in the backend.
  *
  * @param boolean $defaults  Whether to store the global defaults instead
  *                           of user options.
  *
  * @throws Sam_Exception
  */
 public function store($defaults = false)
 {
     if ($defaults) {
         $store = $this->_defaults;
         $user = $this->_params['global_user'];
     } else {
         $store = $this->_options;
         $user = $this->_user;
     }
     foreach ($store as $attribute => $value) {
         $option = $this->_mapAttributeToOption($attribute);
         /* Delete the option if it is the same as the default */
         if (!$defaults && isset($this->_defaults[$attribute]) && $this->_defaults[$attribute] === $value) {
             try {
                 $this->_db->delete('DELETE FROM ' . $this->_params['table'] . ' WHERE username = ? AND preference = ?', array($user, $option));
             } catch (Horde_Db_Exception $e) {
                 throw new Sam_Exception($e);
             }
             continue;
         }
         if (is_array($value)) {
             try {
                 $this->_db->delete('DELETE FROM ' . $this->_params['table'] . ' WHERE username = ? AND preference = ?', array($user, $option));
             } catch (Horde_Db_Exception $e) {
                 throw new Sam_Exception($e);
             }
             foreach ($value as $address) {
                 /* Don't save email addresses already in defaults. */
                 if (!$defaults && isset($this->_defaults[$attribute]) && (is_array($this->_defaults[$attribute]) && in_array($address, $this->_defaults[$attribute]) || $this->_defaults[$attribute] === $address)) {
                     continue;
                 }
                 try {
                     $this->_db->insert('INSERT INTO ' . $this->_params['table'] . ' (username, preference, value)' . ' VALUES (?, ?, ?)', array($user, $option, $address));
                 } catch (Horde_Db_Exception $e) {
                     throw new Sam_Exception($e);
                 }
             }
         } else {
             try {
                 $result = $this->_db->selectValue('SELECT 1 FROM ' . $this->_params['table'] . ' WHERE username = ? AND preference = ?', array($user, $option));
             } catch (Horde_Db_Exception $e) {
                 throw new Sam_Exception($e);
             }
             try {
                 if (!$result) {
                     $this->_db->insert('INSERT INTO ' . $this->_params['table'] . ' (username, preference, value)' . ' VALUES (?, ?, ?)', array($user, $option, $value));
                 } else {
                     $this->_db->insert('UPDATE ' . $this->_params['table'] . ' SET value = ?' . ' WHERE username = ? AND preference = ?', array($value, $user, $option));
                 }
             } catch (Horde_Db_Exception $e) {
                 throw new Sam_Exception($e);
             }
         }
     }
 }
Esempio n. 16
0
File: Sql.php Progetto: horde/horde
 /**
  * Deletes a field from the database.
  *
  * @param integer $field_id  The field id of the field to delete.
  *
  * @return boolean  True on success.
  * @throws Ulaform_Exception
  */
 public function deleteField($field_id)
 {
     /* Delete the field. */
     $sql = 'DELETE FROM ulaform_fields WHERE field_id = ?';
     try {
         $this->_db->delete($sql, array((int) $field_id));
     } catch (Horde_Db_Exception $e) {
         throw new Ulaform_Exception($e->getMessage());
     }
     return true;
 }
Esempio n. 17
0
File: Sql.php Progetto: horde/horde
 /**
  * Delete a set of authentication credentials.
  *
  * @param string $userId  The userId to delete.
  *
  * @throws Horde_Auth_Exception
  */
 public function removeUser($userId)
 {
     /* Build the SQL query. */
     $query = sprintf('DELETE FROM %s WHERE %s = ?', $this->_params['table'], $this->_params['username_field']);
     $values = array($userId);
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Auth_Exception($e);
     }
 }
Esempio n. 18
0
 /**
  * Deletes a forum, any subforums that are present and all messages
  * contained in the forum and subforums.
  *
  * @param integer $forum_id  The ID of the forum to delete.
  *
  * @return boolean  True on success.
  * @throws Agora_Exception
  */
 public function deleteForum($forum_id)
 {
     $this->deleteThread();
     /* Delete the forum itself. */
     try {
         $this->_db->delete('DELETE FROM ' . $this->_forums_table . ' WHERE forum_id = ' . (int) $forum_id);
     } catch (Horde_Db_Exception $e) {
         throw new Agora_Exception($e->getMessage());
     }
     return true;
 }
Esempio n. 19
0
 /**
  * Removes a share from the shares system permanently.
  *
  * @param Horde_Share_Object $share  The share to remove.
  *
  * @return boolean
  * @throws Horde_Share_Exception
  */
 protected function _removeShare(Horde_Share_Object $share)
 {
     $params = array($share->getId());
     $tables = array($this->_table, $this->_table . '_users', $this->_table . '_groups');
     foreach ($tables as $table) {
         try {
             $this->_db->delete('DELETE FROM ' . $table . ' WHERE share_id = ?', $params);
         } catch (Horde_Db_Exception $e) {
             throw new Horde_Share_Exception($e->getMessage());
         }
     }
 }
Esempio n. 20
0
 /**
  * Increments, and returns, the modseq value.
  *
  * @return integer  The new modseq value.
  * @throws Horde_History_Exception
  */
 protected function _nextModSeq()
 {
     try {
         $result = $this->_db->insert('INSERT INTO horde_histories_modseq (history_modseqempty) VALUES(0)');
         // Don't completely empty the table to prevent sequence from being reset
         // when using certain RDBMS, like postgres (see Bug #13876).
         $this->_db->delete('DELETE FROM horde_histories_modseq WHERE history_modseq < (? - 25)', array($result));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_History_Exception($e);
     }
     return $result;
 }
Esempio n. 21
0
 /**
  */
 public function gc($maxlifetime = 300)
 {
     /* Build the SQL query. */
     $query = sprintf('DELETE FROM %s WHERE session_lastmodified < ?', $this->_params['table']);
     $values = array(time() - $maxlifetime);
     /* Execute the query. */
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         return false;
     }
     return true;
 }
Esempio n. 22
0
 /**
  * Do garbage collection needed for the driver.
  */
 public function doGC()
 {
     $now = time();
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE ' . 'lock_expiry_timestamp < ? AND lock_expiry_timestamp != ?';
     $values = array($now, Horde_Lock::PERMANENT);
     try {
         $result = $this->_db->delete($query, $values);
         if ($this->_logger) {
             $this->_logger->log(sprintf('Lock garbage collection cleared %d locks.', $result), 'DEBUG');
         }
     } catch (Horde_Db_Exception $e) {
     }
 }
Esempio n. 23
0
 /**
  */
 public function removeAllVersions($pagename)
 {
     /* Remove attachments and do other cleanup. */
     parent::removeAllVersions($pagename);
     $this->_pageNames = null;
     try {
         $this->_db->beginDbTransaction();
         $this->_db->delete('DELETE FROM ' . $this->_params['table'] . ' WHERE page_name = ?', array($this->_convertToDriver($pagename)));
         $this->_db->delete('DELETE FROM ' . $this->_params['historytable'] . ' WHERE page_name = ?', array($this->_convertToDriver($pagename)));
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         throw new Wicked_Exception($e);
     }
 }
Esempio n. 24
0
 /**
  * Remove the object.
  * NOTE: This does not ensure any references to this object were removed.
  * E.g., does not remove any tags etc... That is client code's
  * responsibility.
  *
  * @param  array $objects  An array of object identifiers to delete.
  * @param  string $type    The type of the objects. All objects must be of
  *                         the same type.
  *
  * @throws Content_Exception
  */
 public function delete(array $objects, $type)
 {
     $type = current($this->_typeManager->ensureTypes($type));
     // Ensure we take the object as a string indentifier.
     foreach ($objects as &$object) {
         $object = strval($object);
     }
     $params = $objects;
     $params[] = $type;
     try {
         $this->_db->delete('DELETE FROM ' . $this->_t('objects') . ' WHERE object_name IN (' . str_repeat('?,', count($objects) - 1) . '?)' . ' AND type_id = ?', $params);
     } catch (Horde_Db_Exception $e) {
         throw new Content_Exception($e);
     }
 }
Esempio n. 25
0
 /**
  * Deletes all notes from the current notepad.
  *
  * @return array  An array of uids that have been removed.
  * @throws Mnemo_Exception
  */
 protected function _deleteAll()
 {
     // Get list of notes we are removing so we can tell history about it.
     $query = sprintf('SELECT memo_uid FROM %s WHERE memo_owner = ?', $this->_table);
     $values = array($this->_notepad);
     try {
         $ids = $this->_db->selectValues($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Mnemo_Exception($e->getMessage());
     }
     $query = sprintf('DELETE FROM %s WHERE memo_owner = ?', $this->_table);
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Mnemo_Exception($e->getMessage());
     }
     return $ids;
 }
Esempio n. 26
0
 /**
  */
 public function remove($scope = null, $pref = null)
 {
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE pref_uid = ?';
     $values = array($this->_params['user']);
     if (!is_null($scope)) {
         $query .= ' AND pref_scope = ?';
         $values[] = $scope;
         if (!is_null($pref)) {
             $query .= ' AND pref_name = ?';
             $values[] = $pref;
         }
     }
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Prefs_Exception($e);
     }
 }
Esempio n. 27
0
 /**
  * Deletes all tasks from the backend.
  *
  * @return array  An array of uids that have been removed.
  * @throws Nag_Exception
  */
 protected function _deleteAll()
 {
     // Get the list of ids so we can notify History.
     $query = sprintf('SELECT task_uid FROM %s WHERE task_owner = ?', $this->_params['table']);
     $values = array($this->_tasklist);
     try {
         $ids = $this->_db->selectValues($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Nag_Exception($e->getMessage());
     }
     // Deletion
     $query = sprintf('DELETE FROM %s WHERE task_owner = ?', $this->_params['table']);
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Nag_Exception($e->getMessage());
     }
     return $ids;
 }
Esempio n. 28
0
 /**
  * Remove all occurrences of a specific tag from an object regardless of
  * the username who tagged the object originally.
  *
  * @param mixed  $obejctId  The object identifier @see Content_Tagger::tag()
  * @param mixed  $tags      The tags to remove. @see Content_Tagger::tag()
  *
  * @return void
  */
 public function removeTagFromObject($objectId, $tags)
 {
     $objectId = $this->_ensureObject($objectId);
     if (!is_array($tags)) {
         $tags = array($tags);
     }
     foreach ($this->ensureTags($tags) as $tagId) {
         // Get the users who have tagged this so we can update the stats
         $users = $this->_db->selectValues('SELECT user_id, tag_id FROM ' . $this->_t('tagged') . ' WHERE object_id = ? AND tag_id = ?', array($objectId, $tagId));
         // Delete the tags
         if ($this->_db->delete('DELETE FROM ' . $this->_t('tagged') . ' WHERE object_id = ? AND tag_id = ?', array($objectId, $tagId))) {
             // Update the stats
             $this->_db->update('UPDATE ' . $this->_t('tag_stats') . ' SET count = count - ' . count($users) . ' WHERE tag_id = ?', array($tagId));
             $this->_db->update('UPDATE ' . $this->_t('user_tag_stats') . ' SET count = count - 1 WHERE user_id IN(' . str_repeat('?, ', count($users) - 1) . '?) AND tag_id = ?', array_merge($users, array($tagId)));
             // Housekeeping
             $this->_db->delete('DELETE FROM ' . $this->_t('tag_stats') . ' WHERE count = 0');
             $this->_db->delete('DELETE FROM ' . $this->_t('user_tag_stats') . ' WHERE count = 0');
         }
     }
 }
Esempio n. 29
0
 /**
  * Deletes all contacts from a specific address book.
  *
  * @param string $sourceName  The source to remove all contacts from.
  *
  * @return array  An array of UIDs
  * @throws Turba_Exception
  */
 protected function _deleteAll($sourceName = null)
 {
     if (!$GLOBALS['registry']->getAuth()) {
         throw new Turba_Exception('Permission denied');
     }
     /* Get owner id */
     $values = empty($sourceName) ? array($GLOBALS['registry']->getAuth()) : array($sourceName);
     /* Need a list of UIDs so we can notify History */
     $query = 'SELECT ' . $this->map['__uid'] . ' FROM ' . $this->_params['table'] . ' WHERE owner_id = ?';
     try {
         $ids = $this->_db->selectValues($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Turba_Exception(_("Server error when deleting data."));
     }
     /* Do the deletion */
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE owner_id = ?';
     try {
         $this->_db->delete($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Turba_Exception(_("Server error when deleting data."));
     }
     return $ids;
 }
Esempio n. 30
0
File: Sql.php Progetto: horde/horde
 /**
  * Deletes an event.
  *
  * @param string $eventId  The ID of the event to delete.
  * @param boolean $silent  Don't send notifications, used when deleting
  *                         events in bulk from maintenance tasks.
  *
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  * @throws Horde_Mime_Exception
  */
 protected function _deleteEvent($eventId, $silent = false)
 {
     /* Fetch the event for later use. */
     if ($eventId instanceof Kronolith_Event) {
         $event = $eventId;
         $eventId = $event->id;
     } else {
         $event = $this->getEvent($eventId);
     }
     $original_uid = $event->uid;
     $isRecurring = $event->recurs();
     $query = 'DELETE FROM kronolith_events WHERE event_id = ? AND calendar_id = ?';
     try {
         $this->_db->delete($query, array($eventId, $this->calendar));
     } catch (Horde_Db_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     /* Notify about the deleted event. */
     if (!$silent) {
         $this->_handleNotifications($event, 'delete');
     }
     /* Now check for any exceptions that THIS event may have */
     if ($isRecurring) {
         $query = 'SELECT event_id FROM kronolith_events WHERE event_baseid = ? AND calendar_id = ?';
         $values = array($original_uid, $this->calendar);
         try {
             $result = $this->_db->selectValues($query, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Kronolith_Exception($e);
         }
         foreach ($result as $id) {
             $this->deleteEvent($id, true);
         }
     }
     return $event;
 }