本文整理汇总了PHP中Horde_Db_Adapter::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Db_Adapter::delete方法的具体用法?PHP Horde_Db_Adapter::delete怎么用?PHP Horde_Db_Adapter::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Db_Adapter
的用法示例。
在下文中一共展示了Horde_Db_Adapter::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMany
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;
}
示例2: purge
/**
* 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);
}
}
示例3: _resetDeviceState
/**
* 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();
}
示例4: removePermission
/**
* 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);
}
}
示例5: _deleteAll
/**
* 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;
}
示例6: purge
/**
* @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);
}
示例7: deleteExternalCollectionId
/**
* 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);
}
}
示例8: removeUser
/**
* 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);
}
}
示例9: delete
/**
* 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;
}
示例10: deleteLocation
/**
* 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);
}
}
示例11: removeImage
/**
* 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);
}
}
示例12: clear
/**
*/
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);
}
}
示例13: _nextModSeq
/**
* 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;
}
示例14: _deleteOldEntries
/**
*/
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) {
}
}
示例15: store
/**
* 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);
}
}
}
}