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


PHP Horde_Db_Adapter::columns方法代码示例

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


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

示例1: get

 /**
  */
 public function get($key, $lifetime = 0)
 {
     $okey = $key;
     $key = hash('md5', $key);
     $timestamp = time();
     $maxage = $timestamp - $lifetime;
     /* Build SQL query. */
     $query = 'SELECT cache_data 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[] = $maxage;
     }
     try {
         $result = $this->_db->selectValue($query, $values);
         $columns = $this->_db->columns($this->_params['table']);
     } catch (Horde_Db_Exception $e) {
         return false;
     }
     if (!$result) {
         /* No rows were found - cache miss */
         if ($this->_logger) {
             $this->_logger->log(sprintf('Cache miss: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
         }
         return false;
     }
     if ($this->_logger) {
         $this->_logger->log(sprintf('Cache hit: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
     }
     return $columns['cache_data']->binaryToString($result);
 }
开发者ID:horde,项目名称:horde,代码行数:34,代码来源:Sql.php

示例2: getMetaData

 /**
  */
 public function getMetaData($mailbox, $uidvalid, $entries)
 {
     $query = $this->_baseSql($mailbox, self::MD_TABLE);
     $query[0] = 'SELECT t.field, t.data ' . $query[0];
     if (!empty($entries)) {
         $entries[] = 'uidvalid';
         $entry_query = array();
         foreach (array_unique($entries) as $val) {
             $entry_query[] = 't.field = ?';
             $query[1][] = $val;
         }
         $query[0] .= ' AND (' . implode(' OR ', $entry_query) . ')';
     }
     try {
         if ($res = $this->_db->selectAssoc($query[0], $query[1])) {
             $columns = $this->_db->columns(self::MD_TABLE);
             foreach ($res as $key => $val) {
                 switch ($key) {
                     case 'uidvalid':
                         $res[$key] = $columns['data']->binaryToString($val);
                         break;
                     default:
                         $res[$key] = @unserialize($columns['data']->binaryToString($val));
                         break;
                 }
             }
             if (is_null($uidvalid) || !isset($res['uidvalid']) || $res['uidvalid'] == $uidvalid) {
                 return $res;
             }
             $this->deleteMailbox($mailbox);
         }
     } catch (Horde_Db_Exception $e) {
     }
     return array();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:37,代码来源:Db.php

示例3: _convertBinary

 /**
  * Converts results from TEXT columns to strings.
  *
  * @param string $column  A column name.
  * @param mixed $value    A TEXT column value.
  *
  * @return string  The column value as plain string.
  */
 protected function _convertBinary($column, $value)
 {
     try {
         $columns = $this->_db->columns($this->_params['table']);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Alarm_Exception(Horde_Alarm_Translation::t("Server error when querying database."));
     }
     return $columns[$column]->binaryToString($value);
 }
开发者ID:horde,项目名称:horde,代码行数:17,代码来源:Sql.php

示例4: get

 /**
  */
 public function get($scope_ob)
 {
     $charset = $this->_db->getOption('charset');
     $query = 'SELECT pref_name, pref_value FROM ' . $this->_params['table'] . ' ' . 'WHERE pref_uid = ? AND pref_scope = ?';
     $values = array($this->_params['user'], $scope_ob->scope);
     try {
         $result = $this->_db->selectAll($query, $values);
         $columns = $this->_db->columns($this->_params['table']);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Prefs_Exception($e);
     }
     foreach ($result as $row) {
         $name = trim($row['pref_name']);
         $value = $columns['pref_value']->binaryToString($row['pref_value']);
         $scope_ob->set($name, Horde_String::convertCharset($value, $charset, 'UTF-8'));
     }
     return $scope_ob;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:20,代码来源:Sql.php

示例5: _convertClobs

 /**
  * Convert clob data to string.
  *
  * @param array &$data  An array of share data.
  */
 protected function _convertClobs(&$data)
 {
     $columns = $this->_db->columns($this->_table);
     foreach ($data as $row => &$value) {
         if (in_array($row, $this->_getClobFields())) {
             $value = $columns[$row]->binaryToString($value);
         }
     }
 }
开发者ID:horde,项目名称:horde,代码行数:14,代码来源:Sql.php

示例6: initialize

 /**
  * Attempts to open a connection to the SQL server.
  *
  * @throws Kronolith_Exception
  */
 public function initialize()
 {
     if (empty($this->_params['db'])) {
         throw new InvalidArgumentException('Missing required Horde_Db_Adapter instance');
     }
     try {
         $this->_db = $this->_params['db'];
     } catch (Horde_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     $this->_columns = $this->_db->columns('kronolith_events');
 }
开发者ID:horde,项目名称:horde,代码行数:17,代码来源:Sql.php

示例7: _getHash

 /**
  */
 protected function _getHash(array $alarm)
 {
     try {
         $columns = $this->_db->columns($this->_params['table']);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Alarm_Exception(Horde_Alarm_Translation::t("Server error when querying database."));
     }
     $alarm['alarm_params'] = $columns['alarm_params']->binaryToString($alarm['alarm_params']);
     $params = base64_decode($alarm['alarm_params']);
     if (!strlen($params) && strlen($alarm['alarm_params'])) {
         $params = $alarm['alarm_params'];
     }
     return array('id' => $alarm['alarm_id'], 'user' => $alarm['alarm_uid'], 'start' => new Horde_Date($alarm['alarm_start'], 'UTC'), 'end' => empty($alarm['alarm_end']) ? null : new Horde_Date($alarm['alarm_end'], 'UTC'), 'methods' => @unserialize($alarm['alarm_methods']), 'params' => @unserialize($params), 'title' => $this->_fromDriver($alarm['alarm_title']), 'text' => $this->_fromDriver($alarm['alarm_text']), 'snooze' => empty($alarm['alarm_snooze']) ? null : new Horde_Date($alarm['alarm_snooze'], 'UTC'), 'internal' => empty($alarm['alarm_internal']) ? null : @unserialize($alarm['alarm_internal']));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:16,代码来源:Sql.php

示例8: read

 /**
  */
 public function read($id)
 {
     /* Begin a transaction. */
     // TODO: Rowlocking in Mysql
     if (!$this->_db->transactionStarted()) {
         $this->_db->beginDbTransaction();
     }
     /* Build query. */
     $query = sprintf('SELECT session_data FROM %s WHERE session_id = ?', $this->_params['table']);
     $values = array($id);
     /* Execute the query. */
     try {
         $columns = $this->_db->columns($this->_params['table']);
         return $columns['session_data']->binaryToString($this->_db->selectValue($query, $values));
     } catch (Horde_Db_Exception $e) {
         return '';
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:20,代码来源:Sql.php

示例9: getSyncCache

 /**
  * Return the sync cache.
  *
  * @param string $devid  The device id.
  * @param string $user   The user id.
  * @param array $fields  An array of fields to return. Default is to return
  *                       the full cache.  @since 2.9.0
  *
  * @return array  The current sync cache for the user/device combination.
  * @throws Horde_ActiveSync_Exception
  */
 public function getSyncCache($devid, $user, array $fields = null)
 {
     $sql = 'SELECT cache_data FROM ' . $this->_syncCacheTable . ' WHERE cache_devid = ? AND cache_user = ?';
     try {
         $data = $this->_db->selectValue($sql, array($devid, $user));
         $columns = $this->_db->columns($this->_syncCacheTable);
         $data = $columns['cache_data']->binaryToString($data);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
     if (!($data = unserialize($data))) {
         $data = array('confirmed_synckeys' => array(), 'lasthbsyncstarted' => false, 'lastsyncendnormal' => false, 'timestamp' => false, 'wait' => false, 'hbinterval' => false, 'folders' => array(), 'hierarchy' => false, 'collections' => array(), 'pingheartbeat' => false, 'synckeycounter' => array());
     }
     if (!is_null($fields)) {
         $data = array_intersect_key($data, array_flip($fields));
     }
     return $data;
 }
开发者ID:platolin,项目名称:horde,代码行数:29,代码来源:Sql.php

示例10: _parseRead

 protected function _parseRead($blobFields, $result, $dateFields = array())
 {
     $results = array();
     foreach ($result as $row) {
         $entry = array();
         foreach ($row as $field => $val) {
             if (isset($blobFields[$field])) {
                 if (!isset($columns)) {
                     $columns = $this->_db->columns($this->_params['table']);
                 }
                 $entry[$field] = $columns[$field]->binaryToString($val);
             } elseif (isset($dateFields[$field]) && !empty($val)) {
                 $d = new Horde_Date($val);
                 $entry[$field] = $this->_convertFromDriver($d->strftime($GLOBALS['attributes'][array_search($field, $this->map)]['params']['format_in']));
             } else {
                 $entry[$field] = $this->_convertFromDriver($val);
             }
         }
         $results[] = $entry;
     }
     return $results;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:22,代码来源:Sql.php

示例11: getRecentImages

 /**
  * Returns a list of Ansel_Images of the most recently added images for the
  * current user.
  *
  * @param array $galleries  An array of gallery ids to search in. If
  *                          left empty, will search all galleries
  *                          with Horde_Perms::SHOW.
  * @param integer $limit    The maximum number of images to return
  * @param string $slugs     An array of gallery slugs.
  * @param string $where     Additional where clause
  *
  * @return array An array of Ansel_Image objects
  * @throws Ansel_Exception
  */
 public function getRecentImages(array $galleries = array(), $limit = 10, array $slugs = array())
 {
     $results = array();
     if (!count($galleries) && !count($slugs)) {
         // Don't need the Ansel_Gallery object, so save some resources and
         // only query the share system.
         foreach ($this->_shares->listShares($GLOBALS['registry']->getAuth()) as $share) {
             $galleries[] = $share->getId();
         }
         if (empty($galleries)) {
             return array();
         }
     }
     if (!count($slugs)) {
         // Searching by gallery_id
         $sql = 'SELECT ' . $this->_getImageFields() . ' FROM ansel_images ' . 'WHERE gallery_id IN (' . str_repeat('?, ', count($galleries) - 1) . '?) ';
         $criteria = $galleries;
     } elseif (count($slugs)) {
         // Searching by gallery_slug so we need to join the share table
         $sql = 'SELECT ' . $this->_getImageFields() . ' FROM ansel_images LEFT JOIN ' . $this->_shares->getTable() . ' ON ansel_images.gallery_id = ' . $this->_shares->getTable() . '.share_id ' . 'WHERE attribute_slug IN (' . str_repeat('?, ', count($slugs) - 1) . '?) ';
         $criteria = $slugs;
     }
     $sql .= ' ORDER BY image_uploaded_date DESC';
     if ($limit > 0) {
         $sql = $this->_db->addLimitOffset($sql, array('limit' => (int) $limit));
     }
     try {
         $images = $this->_db->select($sql, $criteria);
     } catch (Horde_Db_Exception $e) {
         throw new Ansel_Exception($e);
     }
     $columns = $this->_db->columns('ansel_images');
     foreach ($images as $image) {
         $image['image_filename'] = Horde_String::convertCharset($image['image_filename'], $GLOBALS['conf']['sql']['charset'], 'UTF-8');
         $image['image_caption'] = Horde_String::convertCharset($columns['image_caption']->binaryToString($image['image_caption']), $GLOBALS['conf']['sql']['charset'], 'UTF-8');
         $results[] = new Ansel_Image($image);
     }
     return $results;
 }
开发者ID:horde,项目名称:horde,代码行数:53,代码来源:Storage.php


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