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


PHP Horde_Db_Adapter::selectValue方法代码示例

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


在下文中一共展示了Horde_Db_Adapter::selectValue方法的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: _checkTags

 /**
  * Check if tags exists, optionally create them if they don't and return ids
  * for all that exist (including those that are optionally created).
  *
  * @param string|array $tags    The tag names to check.
  * @param boolean      $create  If true, create the tag in the tags table.
  *
  * @return array  A hash of tag_name => tag_id values.
  */
 protected function _checkTags($tags, $create = true)
 {
     if (empty($tags)) {
         return array();
     }
     if (!is_array($tags)) {
         $tags = is_int($tags) ? array($tags) : $this->splitTags($tags);
     }
     $tagIds = array();
     // Anything already typed as an integer is assumed to be a tag id.
     foreach ($tags as $tag) {
         if (is_int($tag)) {
             $tagIds[$tag] = $tag;
             continue;
         }
         // Don't attempt to tag with an empty value
         if (!strlen(trim($tag))) {
             continue;
         }
         // Get the ids for any tags that already exist.
         $sql = 'SELECT tag_id FROM ' . $this->_t('tags') . ' WHERE LOWER(tag_name) = LOWER(' . $this->toDriver($tag) . ')';
         if ($id = $this->_db->selectValue($sql)) {
             $tagIds[$tag] = (int) $id;
         } elseif ($create) {
             // Create any tags that didn't already exist
             $tagIds[$tag] = (int) $this->_db->insert('INSERT INTO ' . $this->_t('tags') . ' (tag_name) VALUES (' . $this->toDriver($tag) . ')');
         }
     }
     return $tagIds;
 }
开发者ID:horde,项目名称:horde,代码行数:39,代码来源:Tagger.php

示例3: getHighestModSeq

 /**
  *  Return the current value of the modseq. We take the MAX of the
  *  horde_histories table instead of the value of the horde_histories_modseq
  *  table to ensure we never miss an entry if we query the history system
  *  between the time we call nextModSeq() and the time the new entry is
  *  written.
  *
  * @param string $parent  Restrict to entries a specific parent.
  *
  * @return integer|boolean  The highest used modseq value, false if no history.
  */
 public function getHighestModSeq($parent = null)
 {
     $sql = 'SELECT history_modseq FROM horde_histories';
     if (!empty($parent)) {
         $sql .= ' WHERE object_uid LIKE ' . $this->_db->quote($parent . ':%');
     }
     $sql .= ' ORDER BY history_modseq DESC';
     $sql = $this->_db->addLimitOffset($sql, array('limit' => 1));
     try {
         $modseq = $this->_db->selectValue($sql);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_History_Exception($e);
     }
     if (is_null($modseq) || $modseq === false) {
         try {
             $modseq = $this->_db->selectValue('SELECT MAX(history_modseq) FROM horde_histories_modseq');
         } catch (Horde_Db_Exception $e) {
             throw new Horde_History_Exception($e);
         }
         if (!empty($modseq)) {
             return $modseq;
         } else {
             return false;
         }
     }
     return $modseq;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:38,代码来源:Sql.php

示例4: 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. */
     $values = array('session_data' => new Horde_Db_Value_Binary($session_data), 'session_lastmodified' => time());
     try {
         if ($exists) {
             $this->_db->updateBlob($this->_params['table'], $values, array('session_id = ?', array($id)));
         } else {
             $this->_db->insertBlob($this->_params['table'], array_merge(array('session_id' => $id), $values));
         }
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         try {
             $this->_db->rollbackDbTransaction();
         } catch (Horde_Db_Exception $e) {
         }
         return false;
     }
     return true;
 }
开发者ID:horde,项目名称:horde,代码行数:32,代码来源:Sql.php

示例5: 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

示例6: exists

 /**
  */
 public function exists($key, $lifetime = 0)
 {
     $okey = $key;
     $key = hash('md5', $key);
     /* Build SQL query. */
     $query = 'SELECT 1 FROM ' . $this->_params['table'] . ' WHERE cache_id = ?';
     $values = array($key);
     // 0 lifetime checks for objects which have no expiration
     if ($lifetime != 0) {
         $query .= ' AND cache_timestamp >= ?';
         $values[] = time() - $lifetime;
     }
     try {
         $result = $this->_db->selectValue($query, $values);
     } catch (Horde_Db_Exception $e) {
         return false;
     }
     $timestamp = time();
     if (empty($result)) {
         if ($this->_logger) {
             $this->_logger->log(sprintf('Cache exists() miss: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
         }
         return false;
     }
     if ($this->_logger) {
         $this->_logger->log(sprintf('Cache exists() hit: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
     }
     return true;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:Sql.php

示例7: 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

示例8: _lookupPolicyID

 /**
  * Returns an Amavisd-new policy for storage and retrieval.
  *
  * @return string  The results of the of the policy lookup. Can be the ID
  *                 of the policy, false if not found.
  * @throws Sam_Exception
  */
 protected function _lookupPolicyID()
 {
     try {
         return $this->_db->selectValue(sprintf('SELECT %s FROM %s WHERE %s = ?', $this->_mapAttributeToField('policies', 'id'), $this->_mapNameToTable('policies'), $this->_mapAttributeToField('policies', 'name')), array($this->_user));
     } catch (Horde_Db_Exception $e) {
         return false;
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:15,代码来源:Sql.php

示例9: getCollectionInterface

 /**
  * Returns an interface name from a stored collection ID map.
  *
  * @param string $external   An external collection ID.
  *
  * @return string  The collection's application.
  *
  * @throws Horde_Dav_Exception
  */
 public function getCollectionInterface($external)
 {
     try {
         return $this->_db->selectValue('SELECT id_interface FROM horde_dav_collections ' . 'WHERE id_external = ?', array($external));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Dav_Exception($e);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:17,代码来源:Sql.php

示例10: getName

 /**
  * Returns a group name.
  *
  * @param mixed $gid  A group ID.
  *
  * @return string  The group's name.
  * @throws Horde_Group_Exception
  */
 public function getName($gid)
 {
     try {
         return $this->_db->selectValue('SELECT group_name FROM horde_groups WHERE group_uid = ?', array($gid));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Group_Exception($e);
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:16,代码来源:Sql.php

示例11: _isSnoozed

 /**
  * Returns whether an alarm is snoozed.
  *
  * @param string $id        The alarm's unique id.
  * @param string $user      The alarm's user
  * @param Horde_Date $time  The time when the alarm may be snoozed.
  *
  * @return boolean  True if the alarm is snoozed.
  * @throws Horde_Alarm_Exception
  */
 protected function _isSnoozed($id, $user, Horde_Date $time)
 {
     $query = sprintf('SELECT 1 FROM %s WHERE alarm_id = ? AND %s AND (alarm_dismissed = 1 OR (alarm_snooze IS NOT NULL AND alarm_snooze >= ?))', $this->_params['table'], !empty($user) ? 'alarm_uid = ?' : '(alarm_uid = ? OR alarm_uid IS NULL)');
     try {
         return $this->_db->selectValue($query, array($id, $user, $time->setTimezone('UTC')->format(Horde_Date::DATE_DEFAULT)));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Alarm_Exception(Horde_Alarm_Translation::t("Server error when querying database."));
     }
 }
开发者ID:horde,项目名称:horde,代码行数:19,代码来源:Sql.php

示例12: _nextFieldOrder

 /**
  * Gets the next field order position within a form.
  *
  * @param integer  $form_id
  *
  * @return integer
  * @throws Ulaform_Exception
  */
 protected function _nextFieldOrder($form_id)
 {
     $sql = 'SELECT MAX(field_order) FROM ulaform_fields WHERE form_id = ?';
     try {
         return $this->_db->selectValue($sql, array($form_id)) + 1;
     } catch (Horde_Db_Exception $e) {
         throw new Ulaform_Exception($e->getMessage);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:17,代码来源:Sql.php

示例13: _getUid

 /**
  * @param string $mailbox
  *
  * @return string  UID from base table.
  */
 protected function _getUid($mailbox)
 {
     $query = $this->_baseSql($mailbox);
     $query[0] = 'SELECT d.messageid ' . $query[0];
     try {
         return $this->_db->selectValue($query[0], $query[1]);
     } catch (Horde_Db_Exception $e) {
         return null;
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:Db.php

示例14: countShares

 /**
  * Returns the count of all shares that $userid has access to.
  *
  * @param string  $userid      The userid of the user to check access for.
  * @param integer $perm        The level of permissions required.
  * @param mixed   $attributes  Restrict the shares counted to those
  *                             matching $attributes. An array of
  *                             attribute/values pairs or a share owner
  *                             username.
  * @param mixed  $parent      The share to start searching from
  *                            (Horde_Share_Object, share_id, or null)
  * @param boolean $allLevels  Return all levels, or just the direct
  *                            children of $parent?
  *
  * @return integer  Number of shares the user has access to.
  * @throws Horde_Share_Exception
  */
 public function countShares($userid, $perm = Horde_Perms::SHOW, $attributes = null, $parent = null, $allLevels = true)
 {
     $query = 'SELECT COUNT(DISTINCT s.share_id) ' . $this->getShareCriteria($userid, $perm, $attributes, $parent, $allLevels);
     try {
         $this->_db->selectValue($query);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Share_Exception($e);
     }
     return $this->_db->selectValue($query);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:27,代码来源:Sql.php

示例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);
             }
         }
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:63,代码来源:Sql.php


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