本文整理汇总了PHP中Horde_Db_Adapter类的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Db_Adapter类的具体用法?PHP Horde_Db_Adapter怎么用?PHP Horde_Db_Adapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Horde_Db_Adapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param Horde_Db_Adapter $connection A DB connection object.
* @param Horde_Log_Logger $logger A logger object.
* @param array $options Additional options for the migrator:
* - migrationsPath: directory with the
* migration files.
* - schemaTableName: table for storing
* the schema version.
*
* @throws Horde_Db_Migration_Exception
*/
public function __construct(Horde_Db_Adapter $connection, Horde_Log_Logger $logger = null, array $options = array())
{
if (!$connection->supportsMigrations()) {
throw new Horde_Db_Migration_Exception('This database does not yet support migrations');
}
$this->_connection = $connection;
$this->_logger = $logger ? $logger : new Horde_Support_Stub();
$this->_inflector = new Horde_Support_Inflector();
if (isset($options['migrationsPath'])) {
$this->_migrationsPath = $options['migrationsPath'];
}
if (isset($options['schemaTableName'])) {
$this->_schemaTableName = $options['schemaTableName'];
}
$this->_initializeSchemaInformation();
}
开发者ID:horde,项目名称:horde,代码行数:29,代码来源:Migrator.php
示例2: 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
示例3: getMany
public function getMany($num = 50)
{
$tasks = array();
$values = array();
$query = 'SELECT * FROM horde_queue_tasks where task_queue = ? ORDER BY task_id LIMIT ?';
$values[] = $this->_queue;
$values[] = $num;
try {
$rows = $this->_db->select($query, $values);
} catch (Horde_Db_Exception $e) {
throw new Horde_Queue_Exception($e);
}
$query = 'DELETE FROM horde_queue_tasks WHERE task_id = ?';
foreach ($rows as $row) {
$tasks[] = unserialize($row['task_fields']);
// TODO: Evaluate if a single call for all IDs is faster for
// various scenarios
try {
$this->_db->delete($query, array($row['task_id']));
} catch (Horde_Db_Exception $e) {
throw new Horde_Queue_Exception($e);
}
}
return $tasks;
}
开发者ID:horde,项目名称:horde,代码行数:25,代码来源:Db.php
示例4: 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
示例5: _resetDeviceState
/**
* Reset the sync state for this device, for the specified collection.
*
* @param string $id The collection to reset.
*
* @return void
* @throws Horde_ActiveSync_Exception
*/
protected function _resetDeviceState($id)
{
$this->_logger->info(sprintf('[%s] Resetting device state for device: %s, user: %s, and collection: %s.', $this->_procid, $this->_deviceInfo->id, $this->_deviceInfo->user, $id));
$state_query = 'DELETE FROM ' . $this->_syncStateTable . ' WHERE sync_devid = ? AND sync_folderid = ? AND sync_user = ?';
$map_query = 'DELETE FROM ' . $this->_syncMapTable . ' WHERE sync_devid = ? AND sync_folderid = ? AND sync_user = ?';
$mailmap_query = 'DELETE FROM ' . $this->_syncMailMapTable . ' WHERE sync_devid = ? AND sync_folderid = ? AND sync_user = ?';
try {
$this->_db->delete($state_query, array($this->_deviceInfo->id, $id, $this->_deviceInfo->user));
$this->_db->delete($map_query, array($this->_deviceInfo->id, $id, $this->_deviceInfo->user));
$this->_db->delete($mailmap_query, array($this->_deviceInfo->id, $id, $this->_deviceInfo->user));
} catch (Horde_Db_Exception $e) {
throw new Horde_ActiveSync_Exception($e);
}
// Remove the collection data from the synccache as well.
$cache = new Horde_ActiveSync_SyncCache($this, $this->_deviceInfo->id, $this->_deviceInfo->user, $this->_logger);
if ($id != Horde_ActiveSync::REQUEST_TYPE_FOLDERSYNC) {
$cache->removeCollection($id, false);
} else {
$this->_logger->notice(sprintf('[%s] Clearing foldersync state from synccache.', $this->_procid));
$cache->clearFolders();
$cache->clearCollections();
$cache->hierarchy = '0';
}
$cache->save();
}
开发者ID:platolin,项目名称:horde,代码行数:33,代码来源:Sql.php
示例6: _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
示例7: _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
示例8: deleteExternalCollectionId
/**
* Deletes an ID map from the backend storage.
*
* @param string $external An external collection ID.
* @param string $interface The collection's application.
*
* @throws Horde_Dav_Exception
*/
public function deleteExternalCollectionId($external, $interface)
{
try {
$this->_db->delete('DELETE FROM horde_dav_collections ' . 'WHERE id_external = ? AND id_interface = ?', array($external, $interface));
} catch (Horde_Db_Exception $e) {
throw new Horde_Dav_Exception($e);
}
}
开发者ID:horde,项目名称:horde,代码行数:16,代码来源:Sql.php
示例9: 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);
}
}
开发者ID:raz0rsdge,项目名称:horde,代码行数:13,代码来源:Storage.php
示例10: search
/**
* Searches for group names.
*
* @param string $name A search string.
*
* @return array A list of matching groups, with IDs as keys and names as
* values.
* @throws Horde_Group_Exception
*/
public function search($name)
{
try {
return $this->_db->selectAssoc('SELECT group_uid, group_name FROM horde_groups WHERE group_name LIKE ?', array('%' . $name . '%'));
} catch (Horde_Db_Exception $e) {
throw new Horde_Group_Exception($e);
}
}
开发者ID:jubinpatel,项目名称:horde,代码行数:17,代码来源:Sql.php
示例11: _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
示例12: _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
示例13: 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);
}
}
开发者ID:raz0rsdge,项目名称:horde,代码行数:14,代码来源:Sql.php
示例14: deleteLocation
/**
* Deletes an entry from storage
*
* @see Kronolith_Geo_Base#removeLocation()
*
* @param string $event_id
*
* @throws Kronolith_Exception
*/
public function deleteLocation($event_id)
{
$sql = 'DELETE FROM kronolith_events_geo WHERE event_id = ?';
try {
$this->_db->delete($sql, array($event_id));
} catch (Horde_Db_Exception $e) {
throw new Horde_Exception($e);
}
}
开发者ID:jubinpatel,项目名称:horde,代码行数:18,代码来源:Sql.php
示例15: clear
/**
*/
public function clear()
{
$query = 'DELETE FROM ' . $this->_params['table'];
try {
$this->_db->delete($query);
} catch (Horde_Db_Exception $e) {
throw new Horde_Cache_Exception($e);
}
}
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:Sql.php
示例16: _deleteOldEntries
/**
*/
protected function _deleteOldEntries($before)
{
/* Build the SQL query. */
$query = sprintf('DELETE FROM %s WHERE sentmail_ts < ?', $this->_params['table']);
/* Execute the query. */
try {
$this->_db->delete($query, array($before));
} catch (Horde_Db_Exception $e) {
}
}
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:12,代码来源:Sql.php
示例17: store
/**
* Stores a foo in the database.
*
* @throws Sms_Exception
*/
public function store($data)
{
$query = 'INSERT INTO skeleton_items' . ' (item_owner, item_data)' . ' VALUES (?, ?)';
$values = array($GLOBALS['registry']->getAuth(), $data);
try {
$this->_db->insert($query, $values);
} catch (Horde_Db_Exception $e) {
throw new Sms_Exception($e->getMessage());
}
}
开发者ID:jubinpatel,项目名称:horde,代码行数:15,代码来源:Sql.php
示例18: 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
示例19: rewind
/**
* Implementation of the rewind() method for iterator.
*/
public function rewind()
{
if ($this->_result) {
unset($this->_result);
}
$this->_current = null;
$this->_index = null;
$this->_eof = true;
$this->_result = $this->_adapter->execute($this->_sql, $this->_arg1, $this->_arg2);
$this->next();
}
开发者ID:lerre,项目名称:framework,代码行数:14,代码来源:Result.php
示例20: add
/**
* Add a token ID.
*
* @param string $tokenID Token ID to add.
*
* @throws Horde_Token_Exception
*/
public function add($tokenID)
{
/* Build SQL query. */
$query = 'INSERT INTO ' . $this->_params['table'] . ' (token_address, token_id, token_timestamp)' . ' VALUES (?, ?, ?)';
$values = array($this->_encodeRemoteAddress(), $tokenID, time());
try {
$this->_db->insert($query, $values);
} catch (Horde_Db_Exception $e) {
throw new Horde_Token_Exception($e);
}
}
开发者ID:horde,项目名称:horde,代码行数:18,代码来源:Sql.php
注:本文中的Horde_Db_Adapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论