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


PHP Horde_Db_Adapter::selectAll方法代码示例

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


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

示例1: ensureUsers

 /**
  * Ensure that an array of users exist in storage. Create any that don't,
  * return user_ids for all.
  *
  * @param array $users  An array of users. Values typed as an integer
  *                        are assumed to already be an user_id.
  *
  * @return array  An array of user_ids.
  */
 public function ensureUsers($users)
 {
     if (!is_array($users)) {
         $users = array($users);
     }
     $userIds = array();
     $userName = array();
     // Anything already typed as an integer is assumed to be a user id.
     foreach ($users as $userIndex => $user) {
         if (is_int($user)) {
             $userIds[$userIndex] = $user;
         } else {
             $userName[$user] = $userIndex;
         }
     }
     // Get the ids for any users that already exist.
     try {
         if (count($userName)) {
             $userName;
             $sql = 'SELECT user_id, user_name FROM ' . $this->_t('users') . ' WHERE user_name IN (' . implode(',', array_map(array($this, 'toDriver'), array_keys($userName))) . ')';
             foreach ($this->_db->selectAll($sql) as $row) {
                 $userIndex = $userName[$row['user_name']];
                 unset($userName[$row['user_name']]);
                 $userIds[$userIndex] = $row['user_id'];
             }
         }
         // Create any users that didn't already exist
         foreach ($userName as $user => $userIndex) {
             $userIds[$userIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('users') . ' (user_name) VALUES (' . $this->toDriver($user) . ')');
         }
     } catch (Horde_Db_Exception $e) {
         throw new Content_Exception($e);
     }
     return $userIds;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:44,代码来源:Manager.php

示例2: init

 /**
  * Loads all rules from the DB backend.
  *
  * @param boolean $readonly  Whether to disable any write operations.
  */
 public function init($readonly = false)
 {
     $query = sprintf('SELECT * FROM %s WHERE rule_owner = ? ORDER BY rule_order', $this->_params['table_rules']);
     $values = array(Ingo::getUser());
     try {
         $result = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Ingo_Exception($e);
     }
     $data = array();
     foreach ($result as $row) {
         $data[$row['rule_order']] = array('id' => (int) $row['rule_id'], 'name' => Horde_String::convertCharset($row['rule_name'], $this->_params['charset'], 'UTF-8'), 'action' => (int) $row['rule_action'], 'action-value' => Horde_String::convertCharset($row['rule_value'], $this->_params['charset'], 'UTF-8'), 'flags' => (int) $row['rule_flags'], 'conditions' => empty($row['rule_conditions']) ? null : Horde_String::convertCharset(unserialize($row['rule_conditions']), $this->_params['charset'], 'UTF-8'), 'combine' => (int) $row['rule_combine'], 'stop' => (bool) $row['rule_stop'], 'disable' => !(bool) $row['rule_active']);
     }
     $this->setFilterlist($data);
     if (empty($data) && !$readonly) {
         $data = @unserialize($GLOBALS['prefs']->getDefault('rules'));
         if ($data) {
             foreach ($data as $val) {
                 $this->addRule($val, false);
             }
         } else {
             $this->addRule(array('name' => 'Whitelist', 'action' => Ingo_Storage::ACTION_WHITELIST), false);
             $this->addRule(array('name' => 'Vacation', 'action' => Ingo_Storage::ACTION_VACATION, 'disable' => true), false);
             $this->addRule(array('name' => 'Blacklist', 'action' => Ingo_Storage::ACTION_BLACKLIST), false);
             $this->addRule(array('name' => 'Spam Filter', 'action' => Ingo_Storage::ACTION_SPAM, 'disable' => true), false);
             $this->addRule(array('name' => 'Forward', 'action' => Ingo_Storage::ACTION_FORWARD), false);
         }
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:34,代码来源:Sql.php

示例3: retrieve

 /**
  * Retrieves the foos from the database.
  *
  * @throws Kolab_Exception
  */
 public function retrieve()
 {
     /* Build the SQL query. */
     $query = 'SELECT * FROM ' . $this->_params['table'] . ' WHERE foo = ?';
     $values = array($this->_params['bar']);
     /* Execute the query. */
     try {
         $rows = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Kolab_Exception($e);
     }
     /* Store the retrieved values in the foo variable. */
     $this->_foo = array_merge($this->_foo, $rows);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:19,代码来源:Sql.php

示例4: retrieve

 /**
  * Retrieves all of the notes of the current notepad from the backend.
  *
  * @throws Mnemo_Exception
  */
 public function retrieve()
 {
     $query = sprintf('SELECT * FROM %s WHERE memo_owner = ?', $this->_table);
     $values = array($this->_notepad);
     try {
         $rows = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Mnemo_Exception($e->getMessage());
     }
     // Store the retrieved values in a fresh list.
     $this->_memos = array();
     foreach ($rows as $row) {
         $this->_memos[$row['memo_id']] = $this->_buildNote($row);
     }
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:20,代码来源:Sql.php

示例5: _getBy

 /**
  * Retrieves one or multiple tasks from the database.
  *
  * @param mixed string|array $taskIds  The ids of the task to retrieve.
  * @param string $column               The column name to search for the ID.
  *
  * @return Nag_Task A Nag_Task object.
  * @throws Horde_Exception_NotFound
  * @throws Nag_Exception
  */
 protected function _getBy($taskIds, $column, array $tasklists = null)
 {
     if (!is_array($taskIds)) {
         $query = 'SELECT * FROM nag_tasks WHERE ' . $column . ' = ?';
         $values = array($taskIds);
     } else {
         if (empty($taskIds)) {
             throw new InvalidArgumentException('Must specify at least one task id');
         }
         $query = 'SELECT * FROM nag_tasks WHERE ' . $column . ' IN (' . implode(',', array_fill(0, count($taskIds), '?')) . ')';
         $values = $taskIds;
     }
     if (!empty($tasklists)) {
         $query .= ' AND task_owner IN (' . implode(',', array_fill(0, count($tasklists), '?')) . ')';
         $values = array_merge($values, $tasklists);
     }
     try {
         $rows = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Nag_Exception($e);
     }
     if (!$rows) {
         throw new Horde_Exception_NotFound(_("Tasks not found"));
     }
     if (!is_array($taskIds)) {
         $results = new Nag_Task($this, $this->_buildTask(reset($rows)));
         $this->_tasklist = $results->tasklist;
     } else {
         $results = new Nag_Task();
         foreach ($rows as $row) {
             $results->add(new Nag_Task($this, $this->_buildTask($row)));
         }
     }
     return $results;
 }
开发者ID:horde,项目名称:horde,代码行数:45,代码来源:Sql.php

示例6: getClientSettings

 /**
  * Fetch client settings from storage.
  *
  * @param integer the client id
  *
  * @return array  A hash of client settings.
  * @throws Hermes_Exception
  */
 public function getClientSettings($clientID)
 {
     $clients = Hermes::listClients();
     if (empty($clientID) || !isset($clients[$clientID])) {
         throw new Horde_Exception_NotFound('Does not exist');
     }
     $sql = 'SELECT clientjob_id, clientjob_enterdescription,' . ' clientjob_exportid FROM hermes_clientjobs' . ' WHERE clientjob_id = ?';
     $values = array($clientID);
     try {
         $rows = $this->_db->selectAll($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Hermes_Exception($e);
     }
     $clientJob = array();
     foreach ($rows as $row) {
         $clientJob[$row['clientjob_id']] = array($row['clientjob_enterdescription'], $row['clientjob_exportid']);
     }
     if (isset($clientJob[$clientID])) {
         $settings = array('id' => $clientID, 'enterdescription' => $clientJob[$clientID][0], 'exportid' => $this->_convertFromDriver($clientJob[$clientID][1]));
     } else {
         $settings = array('id' => $clientID, 'enterdescription' => 1, 'exportid' => null);
     }
     $settings['name'] = $clients[$clientID];
     return $settings;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:Sql.php

示例7: getLocks

 /**
  * Return a list of valid locks with the option to limit the results
  * by principal, scope and/or type.
  *
  * @see Horde_Lock_Base::getLocks()
  */
 public function getLocks($scope = null, $principal = null, $type = null)
 {
     $now = time();
     $sql = 'SELECT lock_id, lock_owner, lock_scope, lock_principal, ' . 'lock_origin_timestamp, lock_update_timestamp, ' . 'lock_expiry_timestamp, lock_type FROM ' . $this->_params['table'] . ' WHERE (lock_expiry_timestamp >= ? OR lock_expiry_timestamp = ?)';
     $values = array($now, Horde_Lock::PERMANENT);
     // Check to see if we need to filter the results
     if (!empty($principal)) {
         $sql .= ' AND lock_principal = ?';
         $values[] = $principal;
     }
     if (!empty($scope)) {
         $sql .= ' AND lock_scope = ?';
         $values[] = $scope;
     }
     if (!empty($type)) {
         $sql .= ' AND lock_type = ?';
         $values[] = $type;
     }
     try {
         $result = $this->_db->selectAll($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Lock_Exception($e);
     }
     $locks = array();
     foreach ($result as $row) {
         $locks[$row['lock_id']] = $row;
     }
     return $locks;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:35,代码来源:Sql.php

示例8: ensureObjects

 /**
  * Ensure that an array of objects exist in storage. Create any that don't,
  * return object_ids for all. All objects in the $objects array must be
  * of the same content type.
  *
  * @param mixed $objects  An array of objects (or single obejct value).
  *                        Values typed as an integer are assumed to already
  *                        be an object_id.
  * @param mixed $type     Either a string type_name or integer type_id
  *
  * @return array  An array of object_ids.
  */
 public function ensureObjects($objects, $type)
 {
     if (!is_array($objects)) {
         $objects = array($objects);
     }
     $objectIds = array();
     $objectName = array();
     $type = current($this->_typeManager->ensureTypes($type));
     // Anything already typed as an integer is assumed to be an object id.
     foreach ($objects as $objectIndex => $object) {
         if (is_int($object)) {
             $objectIds[$objectIndex] = $object;
         } else {
             $objectName[$object] = $objectIndex;
         }
     }
     // Get the ids for any objects that already exist.
     try {
         if (count($objectName)) {
             $rows = $this->_db->selectAll('SELECT object_id, object_name FROM ' . $this->_t('objects') . ' WHERE object_name IN (' . implode(',', array_map(array($this->_db, 'quoteString'), array_keys($objectName))) . ') AND type_id = ' . $type);
             foreach ($rows as $row) {
                 $objectIndex = $objectName[$row['object_name']];
                 unset($objectName[$row['object_name']]);
                 $objectIds[$objectIndex] = $row['object_id'];
             }
         }
         // Create any objects that didn't already exist
         foreach ($objectName as $object => $objectIndex) {
             $objectIds[$objectIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('objects') . ' (object_name, type_id) VALUES (' . $this->_db->quoteString($object) . ', ' . $type . ')');
         }
     } catch (Horde_Db_Exception $e) {
         throw new Content_Exception($e);
     }
     return $objectIds;
 }
开发者ID:Gomez,项目名称:horde,代码行数:47,代码来源:Manager.php

示例9: _read

 /**
  * Reads the given data from the SQL database and returns the results.
  *
  * @param string $key        The primary key field to use.
  * @param mixed $ids         The ids of the contacts to load.
  * @param string $owner      Only return contacts owned by this user.
  * @param array $fields      List of fields to return.
  * @param array $blobFields  Array of fields containing binary data.
  * @param array $dateFields  Array of fields containing date data.
  *                           @since 4.2.0
  *
  * @return array  Hash containing the search results.
  * @throws Turba_Exception
  */
 protected function _read($key, $ids, $owner, array $fields, array $blobFields = array(), array $dateFields = array())
 {
     $values = array();
     $in = '';
     if (is_array($ids)) {
         if (!count($ids)) {
             return array();
         }
         foreach ($ids as $id) {
             $in .= empty($in) ? '?' : ', ?';
             $values[] = $this->_convertToDriver($id);
         }
         $where = $key . ' IN (' . $in . ')';
     } else {
         $where = $key . ' = ?';
         $values[] = $this->_convertToDriver($ids);
     }
     if (isset($this->map['__owner'])) {
         $where .= ' AND ' . $this->map['__owner'] . ' = ?';
         $values[] = $this->_convertToDriver($owner);
     }
     if (!empty($this->_params['filter'])) {
         $where .= ' AND ' . $this->_params['filter'];
     }
     $query = 'SELECT ' . implode(', ', $fields) . ' FROM ' . $this->_params['table'] . ' WHERE ' . $where;
     try {
         return $this->_parseRead($blobFields, $this->_db->selectAll($query, $values), $dateFields);
     } catch (Horde_Db_Exception $e) {
         throw new Turba_Exception(_("Server error when performing search."));
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:45,代码来源:Sql.php

示例10: getFields

 /**
  * Fetches the fields for a particular form.
  *
  * @param integer $form_id  The form id of the form to return.
  *
  * @return array  The fields.
  * @throws Ulaform_Exception
  */
 public function getFields($form_id, $field_id = null)
 {
     $values = array($form_id);
     $sql = 'SELECT field_id, form_id, field_name, field_order, field_label, field_type, ' . ' field_params, field_required, field_readonly, field_desc FROM ulaform_fields ' . ' WHERE form_id = ?';
     if (!is_null($field_id)) {
         $sql .= ' AND field_id = ?';
         $values[] = (int) $field_id;
     }
     $sql .= ' ORDER BY field_order';
     try {
         $results = $this->_db->selectAll($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Ulaform_Exception($e);
     }
     $fields = array();
     foreach ($results as $field) {
         /* If no internal name set, generate one using field_id. */
         if (empty($field['field_name'])) {
             $field['field_name'] = 'field_' . $field['field_id'];
         }
         /* Check if any params and unserialize, otherwise return null. */
         if (!empty($field['field_params'])) {
             $field['field_params'] = Horde_Serialize::unserialize($field['field_params'], Horde_Serialize::UTF7_BASIC);
         } else {
             $field['field_params'] = null;
         }
         $fields[] = $field;
     }
     return $fields;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:38,代码来源:Sql.php

示例11: retrieve

 /**
  * Retrieves the foos from the database.
  *
  * @throws Skeleton_Exception
  */
 public function retrieve()
 {
     /* Build the SQL query. */
     // Unrestricted query
     $query = 'SELECT * FROM skeleton_items';
     // Restricted query alternative
     //$query = 'SELECT * FROM skeleton_items WHERE foo = ?';
     //$values = array($this->_params['bar']);
     /* Execute the query. */
     try {
         $rows = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Skeleton_Exception($e);
     }
     /* Store the retrieved values in the foo variable. */
     $this->_foo = array_merge($this->_foo, $rows);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:22,代码来源:Sql.php

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

示例13: _getHistory

 /**
  * Returns a Horde_History_Log corresponding to the named history entry,
  * with the data retrieved appropriately.
  *
  * @param string $guid  The name of the history entry to retrieve.
  *
  * @return Horde_History_Log  A Horde_History_Log object.
  * @throws Horde_History_Exception
  */
 public function _getHistory($guid)
 {
     try {
         $rows = $this->_db->selectAll('SELECT * FROM horde_histories WHERE object_uid = ?', array($guid));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_History_Exception($e);
     }
     return new Horde_History_Log($guid, $rows);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:18,代码来源:Sql.php

示例14: getAvailableForms

 /**
  * Fetches the a list of available forms to use.
  *
  * @return array  An array of the available forms.
  * @throws Ulaform_Exception
  */
 public function getAvailableForms()
 {
     /* Fetch a list of all forms for now. */
     $sql = 'SELECT form_id, user_uid, form_name, form_action, form_params,' . ' form_onsubmit FROM ulaform_forms';
     try {
         return $this->_db->selectAll($sql);
     } catch (Horde_Db_Exception $e) {
         throw new Ulaform_Exception($e->getMessage());
     }
 }
开发者ID:horde,项目名称:horde,代码行数:16,代码来源:Sql.php

示例15: getByUID

 /**
  * Get an event or events with the given UID value.
  *
  * @param string $uid       The UID to match
  * @param array $calendars  A restricted array of calendar ids to search
  * @param boolean $getAll   Return all matching events?
  *
  * @return Kronolith_Event
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  */
 public function getByUID($uid, $calendars = null, $getAll = false)
 {
     $query = 'SELECT event_id, event_uid, calendar_id, event_description,' . ' event_location, event_private, event_status, event_attendees,' . ' event_title, event_recurcount, event_url, event_timezone,' . ' event_recurtype, event_recurenddate, event_recurinterval,' . ' event_recurdays, event_start, event_end, event_allday,' . ' event_alarm, event_alarm_methods, event_modified,' . ' event_exceptions, event_creator_id, event_resources, event_baseid,' . ' event_exceptionoriginaldate, event_organizer FROM kronolith_events' . ' WHERE event_uid = ?';
     $values = array((string) $uid);
     /* Optionally filter by calendar */
     if (!empty($calendars)) {
         if (!count($calendars)) {
             throw new Kronolith_Exception(_("No calendars to search"));
         }
         $query .= ' AND calendar_id IN (?' . str_repeat(', ?', count($calendars) - 1) . ')';
         $values = array_merge($values, $calendars);
     }
     try {
         $events = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     if (!count($events)) {
         throw new Horde_Exception_NotFound(sprintf(_("%s not found"), $uid));
     }
     $eventArray = array();
     foreach ($events as $event) {
         /* Convert TEXT/CLOB fields. */
         $event = $this->convertBlobs($event);
         $this->open($event['calendar_id']);
         $this->_cache[$this->calendar][$event['event_id']] = new $this->_eventClass($this, $event);
         $eventArray[] = $this->_cache[$this->calendar][$event['event_id']];
     }
     if ($getAll) {
         return $eventArray;
     }
     /* First try the user's own calendars. */
     $ownerCalendars = Kronolith::listInternalCalendars(true, Horde_Perms::READ);
     $event = null;
     foreach ($eventArray as $ev) {
         if (isset($ownerCalendars[$ev->calendar])) {
             $event = $ev;
             break;
         }
     }
     /* If not successful, try all calendars the user has access too. */
     if (empty($event)) {
         $readableCalendars = Kronolith::listInternalCalendars(false, Horde_Perms::READ);
         foreach ($eventArray as $ev) {
             if (isset($readableCalendars[$ev->calendar])) {
                 $event = $ev;
                 break;
             }
         }
     }
     if (empty($event)) {
         $event = $eventArray[0];
     }
     return $event;
 }
开发者ID:horde,项目名称:horde,代码行数:66,代码来源:Sql.php


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