:host => cfg.roundcube_dbhost,
:port => cfg.roundcube_dbport,
:options => cfg.roundcube_dbopts,
- :tty => cfg.roundcube_dbtty,
:dbname => cfg.roundcube_dbname,
:user => cfg.roundcube_dbuser,
:password => cfg.roundcube_dbpass }
def list_users()
usernames = []
- connection = PG::Connection.connect(@db_hash)
+ connection = PG::Connection.new(@db_hash)
sql_query = 'SELECT username FROM users;'
begin
- connection.query(sql_query) do |result|
+ connection.sync_exec(sql_query) do |result|
usernames = result.field_values('username')
end
ensure
sql_query = 'SELECT user_id FROM users WHERE username = $1;'
begin
- connection.query(sql_query, [user.to_s()]) do |result|
+ connection.sync_exec_params(sql_query, [user.to_s()]) do |result|
if result.num_tuples > 0
user_id = result[0]['user_id']
end