本文整理汇总了PHP中Horde_Db_Adapter::selectValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Db_Adapter::selectValues方法的具体用法?PHP Horde_Db_Adapter::selectValues怎么用?PHP Horde_Db_Adapter::selectValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Db_Adapter
的用法示例。
在下文中一共展示了Horde_Db_Adapter::selectValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: 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) {
}
}
}
}
示例3: _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;
}
示例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->updateBlob(self::MD_TABLE, array('data' => $val), array('field = ? AND messageid = ?', array($key, $uid)));
} catch (Horde_Db_Exception $e) {
}
} else {
/* Insert */
try {
$this->_db->insertBlob(self::MD_TABLE, array('data' => $val, 'field' => $key, 'messageid' => $uid));
} catch (Horde_Db_Exception $e) {
}
}
}
}
示例5: favouriteRecipients
/**
*/
public function favouriteRecipients($limit, $filter = null)
{
/* Build the SQL query. */
$where = '';
if (!empty($filter)) {
$filter = array_map(array($this->_db, 'quote'), $filter);
$where = sprintf(' AND sentmail_action in (%s)', implode(', ', $filter));
}
$query = sprintf('SELECT sentmail_recipient, count(*) AS sentmail_count FROM %s WHERE sentmail_who = %s AND sentmail_success = 1%s GROUP BY sentmail_recipient ORDER BY sentmail_count DESC', $this->_params['table'], $this->_db->quote($GLOBALS['registry']->getAuth()), $where);
/* Execute the query. */
try {
$query = $this->_db->addLimitOffset($query, array('limit' => $limit));
return $this->_db->selectValues($query);
} catch (Horde_Db_Exception $e) {
return array();
}
}
示例6: listUsers
/**
* Returns a list of users in a group.
*
* @param mixed $gid A group ID.
*
* @return array List of group users.
* @throws Horde_Group_Exception
*/
public function listUsers($gid)
{
try {
return $this->_db->selectValues('SELECT user_uid FROM horde_groups_members WHERE group_uid = ? ORDER BY user_uid ASC', array($gid));
} catch (Horde_Db_Exception $e) {
throw new Horde_Group_Exception($e);
}
}
示例7: getHashes
/**
* Get a list of all known styleHashes.
*
* @return array An array of style hashes.
*/
public function getHashes()
{
try {
return $this->_db->selectValues('SELECT style_hash FROM ansel_hashes');
} catch (Horde_Db_Exception $e) {
throw new Ansel_Exception($e);
}
}
示例8: listScopes
/**
* Lists all available scopes.
*
* @return array The list of scopes stored in the backend.
*/
public function listScopes()
{
$query = 'SELECT ' . $this->_db->distinct('pref_scope') . ' FROM ' . $this->_params['table'];
try {
return $this->_db->selectValues($query);
} catch (Horde_Db_Exception $e) {
throw new Horde_Prefs_Exception($e);
}
}
示例9: filterEventsByCalendar
/**
* Filters a list of events to return only those that belong to certain
* calendars.
*
* @param array $uids A list of event UIDs.
* @param array $calendar A list of calendar IDs.
*
* @return array Event UIDs filtered by calendar IDs.
* @throws Kronolith_Exception
*/
public function filterEventsByCalendar($uids, $calendar)
{
$sql = 'SELECT event_uid FROM kronolith_events WHERE calendar_id IN (' . str_repeat('?, ', count($calendar) - 1) . '?) ' . 'AND event_uid IN (' . str_repeat('?,', count($uids) - 1) . '?)';
try {
$result = $this->_db->selectValues($sql, array_merge($calendar, $uids));
} catch (Horde_Db_Exception $e) {
throw new Kronolith_Exception($e);
}
return $result;
}
示例10: getSessionIDs
/**
*/
public function getSessionIDs()
{
$this->open();
/* Build the SQL query. */
$query = sprintf('SELECT session_id FROM %s' . ' WHERE session_lastmodified >= ?', $this->_params['table']);
$values = array(time() - ini_get('session.gc_maxlifetime'));
/* Execute the query. */
try {
return $this->_db->selectValues($query, $values);
} catch (Horde_Db_Exception $e) {
return array();
}
}
示例11: listUsers
/**
* List all users in the system.
*
* @param boolean $sort Sort the users?
*
* @return array The array of userIds.
* @throws Horde_Auth_Exception
*/
public function listUsers($sort = false)
{
/* Build the SQL query. */
$query = sprintf('SELECT %s FROM %s', $this->_params['username_field'], $this->_params['table']);
if ($sort) {
$query .= sprintf(' ORDER BY %s ASC', $this->_params['username_field']);
}
try {
return $this->_db->selectValues($query);
} catch (Horde_Db_Exception $e) {
throw new Horde_Auth_Exception($e);
}
}
示例12: _deleteAll
/**
* 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;
}
示例13: listOwners
/**
* Return a list of users who have shares with the given permissions
* for the current user.
*
* @param integer $perm The level of permissions required.
* @param mixed $parent The parent share to start looking in.
* (Horde_Share_Object, share_id, or null)
* @param boolean $allLevels Return all levels, or just the direct
* children of $parent? Defaults to all levels.
* @param integer $from The user to start listing at.
* @param integer $count The number of users to return.
*
* @return array List of users.
* @throws Horde_Share_Exception
*/
public function listOwners($perm = Horde_Perms::SHOW, $parent = null, $allLevels = true, $from = 0, $count = 0)
{
$sql = 'SELECT DISTINCT(s.share_owner) ' . $this->getShareCriteria($this->_user, $perm, null, $parent, $allLevels);
if ($count) {
$sql = $this->_db->addLimitOffset($sql, array('limit' => $count, 'offset' => $from));
}
try {
$allowners = $this->_db->selectValues($sql);
} catch (Horde_Db_Exception $e) {
throw new Horde_Share_Exception($e);
}
$owners = array();
foreach ($allowners as $owner) {
if ($this->countShares($this->_user, $perm, $owner, $parent, $allLevels)) {
$owners[] = $owner;
}
}
return $owners;
}
示例14: _deleteAll
/**
* 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;
}
示例15: getForum
/**
* Fetches a forum data.
*
* @param integer $forum_id The ID of the forum to fetch.
*
* @return array The forum hash or a PEAR_Error on failure.
* @throws Horde_Exception_NotFound
* @throws Agora_Exception
*/
public function getForum($forum_id = 0)
{
if (!$forum_id) {
$forum_id = $this->_forum_id;
} elseif ($forum_id instanceof PEAR_Error) {
return $forum_id;
}
// Make the requested forum the current forum
$this->_forum_id = $forum_id;
/* Check if we can read messages in this forum */
if (!$this->hasPermission(Horde_Perms::SHOW, $forum_id)) {
return PEAR::raiseError(sprintf(_("You don't have permission to access messages in forum %s."), $forum_id));
}
$forum = $this->_cache->get('agora_forum_' . $forum_id, $GLOBALS['conf']['cache']['default_lifetime']);
if ($forum) {
return unserialize($forum);
}
$sql = 'SELECT forum_id, forum_name, scope, active, forum_description, ' . 'forum_parent_id, forum_moderated, forum_attachments, ' . 'forum_distribution_address, author, message_count, thread_count ' . 'FROM ' . $this->_forums_table . ' WHERE forum_id = ?';
try {
$forum = $this->_db->selectOne($sql, array($forum_id));
} catch (Horde_Db_Exception $e) {
throw new Agora_Exception($e->getMessage());
}
if (empty($forum)) {
throw new Horde_Exception_NotFound(sprintf(_("Forum %s does not exist."), $forum_id));
}
$forum['forum_name'] = $this->convertFromDriver($forum['forum_name']);
$forum['forum_description'] = $this->convertFromDriver($forum['forum_description']);
$forum['forum_distribution_address'] = $this->convertFromDriver($forum['forum_distribution_address']);
/* Get moderators */
$sql = 'SELECT horde_uid FROM agora_moderators WHERE forum_id = ?';
try {
$moderators = $this->_db->selectValues($sql, array($forum_id));
} catch (Horde_Db_Exception $e) {
throw new Agora_Exception($e->getMessage());
}
if (!empty($moderators)) {
$forum['moderators'] = $moderators;
}
$this->_cache->set('agora_forum_' . $forum_id, serialize($forum));
return $forum;
}