root/trunk/src/shared/Database/DatabaseMysql.h @ 102

Revision 102, 2.3 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef DO_POSTGRESQL
22
23#ifndef _DATABASEMYSQL_H
24#define _DATABASEMYSQL_H
25
26#include "Database.h"
27#include "Policies/Singleton.h"
28#include "zthread/FastMutex.h"
29
30#ifdef WIN32
31#define FD_SETSIZE 1024
32#include <winsock2.h>
33#include <mysql/mysql.h>
34#else
35#include <mysql.h>
36#endif
37
38class TRINITY_DLL_SPEC DatabaseMysql : public Database
39{
40    friend class Trinity::OperatorNew<DatabaseMysql>;
41
42    public:
43        DatabaseMysql();
44        ~DatabaseMysql();
45
46        //! Initializes Mysql and connects to a server.
47        /*! infoString should be formated like hostname;username;password;database. */
48        bool Initialize(const char *infoString);
49        void InitDelayThread();
50        void HaltDelayThread();
51        QueryResult* Query(const char *sql);
52        bool Execute(const char *sql);
53        bool DirectExecute(const char* sql);
54        bool BeginTransaction();
55        bool CommitTransaction();
56        bool RollbackTransaction();
57
58        operator bool () const { return mMysql != NULL; }
59
60        unsigned long escape_string(char *to, const char *from, unsigned long length);
61        using Database::escape_string;
62
63        // must be call before first query in thread
64        void ThreadStart();
65        // must be call before finish thread run
66        void ThreadEnd();
67    private:
68        ZThread::FastMutex mMutex;
69
70        ZThread::ThreadImpl* tranThread;
71
72        MYSQL *mMysql;
73
74        static size_t db_count;
75
76        bool _TransactionCmd(const char *sql);
77};
78#endif
79#endif
Note: See TracBrowser for help on using the browser.