[go: up one dir, main page]

Menu

[r301]: / mysqlconnection.cpp  Maximize  Restore  History

Download this file

43 lines (33 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Marcion
Copyright (C) 2009 - 2011 Milan Konvicka
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program */
#include "mysqlconnection.h"
CMySqlConnection::CMySqlConnection(CMessages * const messages)
:messages(messages)
{
}
bool CMySqlConnection::connect()
{
messages->MsgMsg(QObject::tr("connecting remote database - DATABASE NAME: '")+messages->settings().db()+"' HOST: '"+messages->settings().host()+"' PORT: '"+QString::number(messages->settings().port())+"' USER: '"+messages->settings().user()+"' PASSWORD: '"+messages->settings().pwd()+"' ...");
if(CMySql::connect(messages->settings().host(),
messages->settings().user(),
messages->settings().pwd(),
messages->settings().db(),
messages->settings().port()))
return true;
messages->MsgErr(CMySql::lastConnectError());
return false;
}
void CMySqlConnection::disconnect()
{
CMySql::close();
messages->MsgMsg(QObject::tr("disconnected."));
}