当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Db_Adapter::update方法代码示例

本文整理汇总了PHP中Horde_Db_Adapter::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Db_Adapter::update方法的具体用法?PHP Horde_Db_Adapter::update怎么用?PHP Horde_Db_Adapter::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Horde_Db_Adapter的用法示例。


在下文中一共展示了Horde_Db_Adapter::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setLocation

 /**
  * Set the location of the specified event _id
  *
  * @see Kronolith_Geo_Base#setLocation()
  * @throws Kronolith_Exception
  */
 public function setLocation($event_id, $point)
 {
     /* First make sure it doesn't already exist */
     $sql = 'SELECT COUNT(*) FROM kronolith_events_geo WHERE event_id = ?';
     try {
         $count = $this->_db->selectValue($sql, array($event_id));
     } catch (Horde_Db_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     /* Do we actually have data? If not, see if we are deleting an
      * existing entry. */
     if ((empty($point['lat']) || empty($point['lon'])) && $count) {
         // Delete the record.
         $this->deleteLocation($event_id);
         return;
     } elseif (empty($point['lat']) || empty($point['lon'])) {
         return;
     }
     if (empty($point['zoom'])) {
         $point['zoom'] = 0;
     }
     /* INSERT or UPDATE */
     $params = array($point['lat'], $point['lon'], $point['zoom'], $event_id);
     try {
         if ($count) {
             $sql = 'UPDATE kronolith_events_geo SET event_lat = ?, event_lon = ?, event_zoom = ? WHERE event_id = ?';
             $this->_db->update($sql, $params);
         } else {
             $sql = 'INSERT into kronolith_events_geo (event_lat, event_lon, event_zoom, event_id) VALUES(?, ?, ?, ?)';
             $this->_db->insert($sql, $params);
         }
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Exception($e);
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:41,代码来源:Sql.php

示例2: saveSyncCache

 /**
  * Save the provided sync_cache.
  *
  * @param array $cache   The cache to save.
  * @param string $devid  The device id.
  * @param string $user   The user id.
  * @param array $dirty   An array of dirty properties. @since 2.9.0
  *
  * @throws Horde_ActiveSync_Exception
  */
 public function saveSyncCache(array $cache, $devid, $user, array $dirty = null)
 {
     $cache['timestamp'] = strval($cache['timestamp']);
     $sql = 'SELECT count(*) FROM ' . $this->_syncCacheTable . ' WHERE cache_devid = ? AND cache_user = ?';
     try {
         $have = $this->_db->selectValue($sql, array($devid, $user));
     } catch (Horde_Db_Exception $e) {
         $this->_logger->err(sprintf('[%s] %s', $this->_procid, $e->getMessage()));
         throw new Horde_ActiveSync_Exception($e);
     }
     $cache = serialize($cache);
     if ($have) {
         $this->_logger->info(sprintf('[%s] Replacing SYNC_CACHE entry for user %s and device %s: %s', $this->_procid, $user, $devid, $cache));
         $sql = 'UPDATE ' . $this->_syncCacheTable . ' SET cache_data = ? WHERE cache_devid = ? AND cache_user = ?';
         try {
             $this->_db->update($sql, array($cache, $devid, $user));
         } catch (Horde_Db_Exception $e) {
             $this->_logger->err(sprintf('[%s] %s', $this->_procid, $e->getMessage()));
             throw new Horde_ActiveSync_Exception($e);
         }
     } else {
         $this->_logger->info(sprintf('[%s] Adding new SYNC_CACHE entry for user %s and device %s: %s', $this->_procid, $user, $devid, $cache));
         $sql = 'INSERT INTO ' . $this->_syncCacheTable . ' (cache_data, cache_devid, cache_user) VALUES (?, ?, ?)';
         try {
             $this->_db->insert($sql, array($cache, $devid, $user));
         } catch (Horde_Db_Exception $e) {
             $this->_logger->err(sprintf('[%s] %s', $this->_procid, $e->getMessage()));
             throw new Horde_ActiveSync_Exception($e);
         }
     }
 }
开发者ID:platolin,项目名称:horde,代码行数:41,代码来源:Sql.php

示例3: write

 /**
  */
 public function write($id, $session_data)
 {
     if (!$this->_db->isActive()) {
         $this->_db->reconnect();
         $this->_db->beginDbTransaction();
     }
     /* Check if session exists. */
     try {
         $exists = $this->_db->selectValue(sprintf('SELECT 1 FROM %s WHERE session_id = ?', $this->_params['table']), array($id));
     } catch (Horde_Db_Exception $e) {
         return false;
     }
     /* Update or insert session data. */
     $session_data = new Horde_Db_Value_Binary($session_data);
     try {
         if ($exists) {
             $query = sprintf('UPDATE %s ' . 'SET session_data = ?, session_lastmodified = ? ' . 'WHERE session_id = ?', $this->_params['table']);
             $values = array($session_data, time(), $id);
             $this->_db->update($query, $values);
         } else {
             $query = sprintf('INSERT INTO %s ' . '(session_id, session_data, session_lastmodified) ' . 'VALUES (?, ?, ?)', $this->_params['table']);
             $values = array($id, $session_data, time());
             $this->_db->insert($query, $values);
         }
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         try {
             $this->_db->rollbackDbTransaction();
         } catch (Horde_Db_Exception $e) {
         }
         return false;
     }
     return true;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:36,代码来源:Sql.php

示例4: setMetaData

 /**
  */
 public function setMetaData($mailbox, $data)
 {
     if (!($uid = $this->_getUid($mailbox))) {
         $uid = $this->_createUid($mailbox);
     }
     $query = sprintf('SELECT field FROM %s where messageid = ?', self::MD_TABLE);
     $values = array($uid);
     try {
         $fields = $this->_db->selectValues($query, $values);
     } catch (Horde_Db_Exception $e) {
         return;
     }
     foreach ($data as $key => $val) {
         $val = new Horde_Db_Value_Binary($key == 'uidvalid' ? $val : serialize($val));
         if (in_array($key, $fields)) {
             /* Update */
             try {
                 $this->_db->update(sprintf('UPDATE %s SET data = ? WHERE field = ? AND messageid = ?', self::MD_TABLE), array($val, $key, $uid));
             } catch (Horde_Db_Exception $e) {
             }
         } else {
             /* Insert */
             try {
                 $this->_db->insert(sprintf('INSERT INTO %s (data, field, messageid) VALUES (?, ?, ?)', self::MD_TABLE), array($val, $key, $uid));
             } catch (Horde_Db_Exception $e) {
             }
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:Db.php

示例5: _modify

 /**
  * Modifies a SQL password record for a user.
  *
  * @param string $user     The user whose record we will udpate.
  * @param string $newpass  The new password value to set.
  *
  * @throws Passwd_Exception
  */
 protected function _modify($user, $newpass)
 {
     /* Only split up username if domain is set in backend. */
     if ($this->_params['domain']) {
         list($name, $domain) = explode('@', $user);
     } else {
         $name = $user;
     }
     /* Encrypt the password. */
     $clear_password = $newpass;
     $newpass = $this->_encryptPassword($newpass);
     /* Build the SQL query. */
     $sql = 'UPDATE ' . $this->_params['table'] . ' SET ' . $this->_params['passwd'] . ' = ?';
     $values = array($newpass);
     if ($this->_params['use_clear_passwd']) {
         $sql .= ', ' . $this->_params['clear_passwd'] . ' = ?';
         $values[] = $clear_password;
     }
     $sql .= ' WHERE ' . $this->_params['name'] . ' = ?';
     $values[] = $name;
     if ($this->_params['domain']) {
         $sql .= ' AND ' . $this->_params['domain'] . ' = ?';
         $values[] = $domain;
     }
     /* Execute the query. */
     try {
         $this->_db->update($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Passwd_Exception($e);
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:39,代码来源:Vpopmail.php

示例6: updateClientSettings

 /**
  * @TODO
  *
  * @param <type> $clientID
  * @param <type> $enterDescription
  * @param string $exportID
  * @return <type>
  */
 public function updateClientSettings($clientID, $enterDescription = 1, $exportID = null)
 {
     if (empty($exportID)) {
         $exportID = null;
     }
     $sql = 'SELECT clientjob_id FROM hermes_clientjobs WHERE clientjob_id = ?';
     $values = array($clientID);
     if ($this->_db->selectValue($sql, $values) !== $clientID) {
         $sql = 'INSERT INTO hermes_clientjobs (clientjob_id,' . ' clientjob_enterdescription, clientjob_exportid)' . ' VALUES (?, ?, ?)';
         $values = array($clientID, (int) $enterDescription, $this->_convertToDriver($exportID));
         try {
             return $this->_db->insert($sql, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Hermes_Exception($e);
         }
     } else {
         $sql = 'UPDATE hermes_clientjobs SET' . ' clientjob_exportid = ?, clientjob_enterdescription = ?' . ' WHERE clientjob_id = ?';
         $values = array($this->_convertToDriver($exportID), (int) $enterDescription, $clientID);
         try {
             return $this->_db->update($sql, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Hermes_Exception($e);
         }
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:Sql.php

示例7: set

 /**
  */
 public function set($mailbox, $data, $uidvalid)
 {
     if ($uid = $this->_getUid($mailbox)) {
         $res = $this->get($mailbox, array_keys($data), array(), $uidvalid);
     } else {
         $res = array();
         $uid = $this->_createUid($mailbox);
     }
     $compress = new Horde_Compress_Fast();
     foreach ($data as $key => $val) {
         if (isset($res[$key])) {
             try {
                 /* Update */
                 $this->_db->updateBlob(self::MSG_TABLE, array('data' => new Horde_Db_Value_Binary($compress->compress(serialize(array_merge($res[$key], $val))))), array('messageid = ? AND msguid = ?', array($uid, strval($key))));
             } catch (Horde_Db_Exception $e) {
             }
         } else {
             /* Insert */
             try {
                 $this->_db->insertBlob(self::MSG_TABLE, array('data' => new Horde_Db_Value_Binary($compress->compress(serialize($val))), 'msguid' => strval($key), 'messageid' => $uid));
             } catch (Horde_Db_Exception $e) {
             }
         }
     }
     /* Update modified time. */
     try {
         $this->_db->update(sprintf('UPDATE %s SET modified = ? WHERE messageid = ?', self::BASE_TABLE), array(time(), $uid));
     } catch (Horde_Db_Exception $e) {
     }
     /* Update uidvalidity. */
     $this->setMetaData($mailbox, array('uidvalid' => $uidvalid));
 }
开发者ID:horde,项目名称:horde,代码行数:34,代码来源:Db.php

示例8: _renameShare

 /**
  * Renames a share in the shares system.
  *
  * @param Horde_Share_Object $share  The share to rename.
  * @param string $name               The share's new name.
  *
  * @throws Horde_Share_Exception
  */
 protected function _renameShare(Horde_Share_Object $share, $name)
 {
     try {
         $this->_db->update('UPDATE ' . $this->_table . ' SET share_name = ? WHERE share_id = ?', array($name, $share->getId()));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Share_Exception($e);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:16,代码来源:Sql.php

示例9: setImagesGallery

 /**
  * Set the gallery id for a set of images. Useful for bulk updating images
  * when moving from one gallery to another.
  *
  * @param array $image_ids     An array of image ids
  * @param integer $gallery_id  The gallery id to move the images to.
  *
  * @throws Ansel_Exception
  */
 public function setImagesGallery(array $image_ids, $gallery_id)
 {
     try {
         $this->_db->update('UPDATE ansel_images SET gallery_id = ' . $gallery_id . ' WHERE image_id IN (' . implode(',', $image_ids) . ')');
     } catch (Horde_Db_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Ansel_Exception($e);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:18,代码来源:Storage.php

示例10: update

 /**
  * Executes the update 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 update($sql, $arg1 = null, $arg2 = null)
 {
     $result = $this->_write->update($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;
 }
开发者ID:horde,项目名称:horde,代码行数:21,代码来源:SplitRead.php

示例11: _dismiss

 /**
  * Dismisses an alarm.
  *
  * @param string $id          The alarm's unique id.
  * @param string $user        The alarm's user
  *
  * @throws Horde_Alarm_Exception
  */
 protected function _dismiss($id, $user)
 {
     $query = sprintf('UPDATE %s set alarm_dismissed = 1 WHERE alarm_id = ? AND %s', $this->_params['table'], !empty($user) ? 'alarm_uid = ?' : '(alarm_uid = ? OR alarm_uid IS NULL)');
     $values = array($id, $user);
     try {
         $this->_db->update($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Alarm_Exception(Horde_Alarm_Translation::t("Server error when querying database."));
     }
 }
开发者ID:horde,项目名称:horde,代码行数:18,代码来源:Sql.php

示例12: setData

 /**
  * Sets one or more attributes of a group.
  *
  * @param mixed $gid               A group ID.
  * @param array|string $attribute  An attribute name or a hash of
  *                                 attributes.
  * @param string $value            An attribute value if $attribute is a
  *                                 string.
  *
  * @throws Horde_Group_Exception
  */
 public function setData($gid, $attribute, $value = null)
 {
     $attributes = is_array($attribute) ? $attribute : array($attribute => $value);
     $updates = array();
     foreach ($attributes as $attribute => $value) {
         $updates[] = $this->_db->quoteColumnName('group_' . $attribute) . ' = ' . $this->_db->quote($value);
     }
     try {
         $this->_db->update('UPDATE horde_groups SET ' . implode(', ', $updates) . ' WHERE group_uid = ?', array($gid));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Group_Exception($e);
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:24,代码来源:Sql.php

示例13: _move

 /**
  * Moves an event to a new calendar.
  *
  * @param string $eventId      The event to move.
  * @param string $newCalendar  The new calendar.
  *
  * @return Kronolith_Event  The old event.
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  */
 protected function _move($eventId, $newCalendar)
 {
     /* Fetch the event for later use. */
     $event = $this->getEvent($eventId);
     $query = 'UPDATE kronolith_events SET calendar_id = ? WHERE calendar_id = ? AND event_id = ?';
     $values = array($newCalendar, $this->calendar, $eventId);
     /* Attempt the move query. */
     try {
         $this->_db->update($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     return $event;
 }
开发者ID:horde,项目名称:horde,代码行数:24,代码来源:Sql.php

示例14: resetLock

 /**
  * Extend the valid lifetime of a valid lock to now + $lifetime.
  *
  * @see Horde_Lock_Base::resetLock()
  */
 public function resetLock($lockid, $lifetime)
 {
     $now = time();
     if (!$this->getLockInfo($lockid)) {
         return false;
     }
     $expiration = $lifetime == Horde_Lock::PERMANENT ? Horde_Lock::PERMANENT : $now + $lifetime;
     $sql = 'UPDATE ' . $this->_params['table'] . ' SET ' . 'lock_update_timestamp = ?, lock_expiry_timestamp = ? ' . 'WHERE lock_id = ? AND lock_expiry_timestamp <> ?';
     $values = array($now, $expiration, $lockid, Horde_Lock::PERMANENT);
     try {
         $this->_db->update($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Lock_Exception($e);
     }
     return true;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:21,代码来源:Sql.php

示例15: sort

 /**
  */
 public function sort($rules)
 {
     $old = $this->_filters;
     parent::sort($rules);
     $query = sprintf('UPDATE %s SET rule_order = ? WHERE rule_id = ?', $this->_params['table_rules']);
     $this->_db->beginDbTransaction();
     try {
         foreach ($this->_filters as $key => $val) {
             $this->_db->update($query, array($key, $val['id']));
         }
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         $this->_filters = $old;
         throw new Ingo_Exception($e);
     }
     $this->_db->commitDbTransaction();
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:19,代码来源:Sql.php


注:本文中的Horde_Db_Adapter::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。