Exemplo n.º 1
0
 /**
  * TODO
  *
  * @param string $table      TODO
  * @param string $field      TODO
  * @param string $data       TODO
  * @param string $where      TODO
  * @param array $alsoupdate  TODO
  *
  * @return mixed  TODO
  * @throws Horde_Vfs_Exception
  */
 protected function _updateBlob($table, $field, $data, $where, $alsoupdate)
 {
     $updatestring = '';
     $values = array();
     foreach ($alsoupdate as $key => $value) {
         $updatestring .= $key . ' = ?, ';
         $values[] = $value;
     }
     $updatestring .= $field . ' = ?';
     $values[] = new Horde_Db_Value_Binary($data);
     $wherestring = '';
     foreach ($where as $key => $value) {
         if (!empty($wherestring)) {
             $wherestring .= ' AND ';
         }
         $wherestring .= $key . ' = ?';
         $values[] = $value;
     }
     $query = sprintf('UPDATE %s SET %s WHERE %s', $table, $updatestring, $wherestring);
     /* Execute the query. */
     try {
         $this->_db->update($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Vfs_Exception($e);
     }
 }
Exemplo n.º 2
0
Arquivo: Sql.php Projeto: horde/horde
 /**
  * Saves virtual email address to the backend.
  *
  * @param array $info     The virtual email data.
  * @param string $domain  The name of the domain for this virtual email.
  *
  * @throws Vilma_Exception
  */
 public function saveVirtual($info, $domain)
 {
     /* Access check (for domainkey) */
     $this->getDomainByName($domain);
     $values = array($info['stripped_email'] . '@' . $domain, $info['virtual_destination']);
     if (empty($info['virtual_id'])) {
         $sql = 'INSERT INTO ' . $this->_params['tables']['virtuals'] . ' (' . $this->_getTableField('virtuals', 'virtual_email') . ', ' . $this->_getTableField('virtuals', 'virtual_destination') . ') VALUES (?, ?)';
         $this->_db->insert($sql, $values);
     } else {
         $sql = 'UPDATE ' . $this->_params['tables']['virtuals'] . ' SET ' . $this->_getTableField('virtuals', 'virtual_email') . ' = ?, ' . $this->_getTableField('virtuals', 'virtual_destination') . ' = ?' . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_id') . ' = ?';
         $values[] = $info['virtual_id'];
         $this->_db->update($sql, $values);
     }
 }
Exemplo n.º 3
0
Arquivo: Sql.php Projeto: horde/horde
 /**
  * Renames all child paths.
  *
  * @param string $path  The path of the folder to rename.
  * @param string $name  The foldername to use.
  *
  * @throws Horde_Vfs_Exception
  */
 protected function _recursiveRename($oldpath, $oldname, $newpath, $newname)
 {
     $oldpath = $this->_convertPath($oldpath);
     $newpath = $this->_convertPath($newpath);
     $sql = sprintf('SELECT vfs_name FROM %s WHERE vfs_type = ? AND vfs_path = ?', $this->_params['table']);
     $values = array(self::FOLDER, $this->_getNativePath($oldpath, $oldname));
     try {
         $folderList = $this->_db->selectValues($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Vfs_Exception($e);
     }
     foreach ($folderList as $folder) {
         $this->_recursiveRename($this->_getNativePath($oldpath, $oldname), $folder, $this->_getNativePath($newpath, $newname), $folder);
     }
     $sql = sprintf('UPDATE %s SET vfs_path = ? WHERE vfs_path = ?', $this->_params['table']);
     $values = array($this->_getNativePath($newpath, $newname), $this->_getNativePath($oldpath, $oldname));
     try {
         $this->_db->update($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Vfs_Exception($e);
     }
 }