/** * Read file data from the SQL VFS backend. * * @param string $table The VFS table name. * @param string $field TODO * @param array $criteria TODO * * @return mixed TODO * @throws Horde_Vfs_Exception */ protected function _readBlob($table, $field, $criteria) { if (!count($criteria)) { throw new Horde_Vfs_Exception('You must specify the fetch criteria'); } $where = ''; foreach ($criteria as $key => $value) { if (!empty($where)) { $where .= ' AND '; } $where .= $key . ' = ' . $this->_db->quote($value); } $sql = sprintf('SELECT %s FROM %s WHERE %s', $field, $table, $where); try { $result = $this->_db->selectValue($sql); $columns = $this->_db->columns($table); } catch (Horde_Db_Exception $e) { throw new Horde_Vfs_Exception($e); } if ($result === false) { throw new Horde_Vfs_Exception('Unable to load SQL data.'); } return $columns[$field]->binaryToString($result); }
/** * Returns the current number of users for a domain. * * @param string $domain_name The name of the domain for which to * get the current number of users. * * @return integer The current number of users. */ public function getDomainNumUsers($domain_name) { $sql = 'SELECT count(' . $this->_getTableField('users', 'user_name') . ')' . ' FROM ' . $this->_params['tables']['users'] . ' WHERE ' . $this->_getTableField('users', 'user_name') . ' LIKE ?'; return $this->_db->selectValue($sql, array('%@' . $domain_name)); }