/* 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."));
}