本文整理汇总了PHP中Horde_Db_Adapter类的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Db_Adapter类的具体用法?PHP Horde_Db_Adapter怎么用?PHP Horde_Db_Adapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Horde_Db_Adapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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;
}
示例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);
}
示例4: _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();
}
示例5: _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);
}
}
示例6: _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;
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: _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);
}
}
示例11: _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);
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: 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);
}
}
示例15: _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) {
}
}