GithubHelp home page GithubHelp logo

richmondx / ue4-mysqlplugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anhanjinj/ue4-mysqlplugin

1.0 2.0 0.0 50.89 MB

a UE4 plugin for MySQL

C# 0.13% C++ 49.93% C 42.19% Objective-C 2.87% Pascal 4.89%

ue4-mysqlplugin's Introduction

UE4-MySQLPlugin

///////////////////////////////////////////////////

a UE4 plugin for MySQL @author [email protected] 2016/11/16

if you find any bug , you can send a email to my email: [email protected]

//////////////////////////////////////////////////

support database:
	
		*mysql-5.7.16

later will support:	
	
	*postgresql

//////////////////////////////////////////////////

to use this plugin you shuld:

  1. set up mysql in your pc.

  2. add A plugin folder in your project, then copy "DBSupport" under it, restart your project.

  3. if your project has vsproject, your build.cs should add "DBSupport" moudle :

     PublicDependencyModuleNames.AddRange(new string[] { ....."DBSupport", ..... });
    
  4. add "#include "DBSupport.h" in the file which you want use the plugin.

///////////////////////////////////////////////////////

example code:

	#include "MyP.h"
	#include "MyPGameModeBase.h"
	
	#include "DBSupport.h"
	using namespace DBBase;




	void AMyPGameModeBase::StartPlay()
	{
		Super::StartPlay();

		
		if (IDBSupportPlugin::IsAvailable())
		{

			//init connection
			DBBase::IConnection * pDBC = IDBSupportPlugin::Get().GetConnection(MYSQL_CONNECTION);


			if (pDBC)
			{
				GEngine->AddOnScreenDebugMessage(-1, -1, FColor::Red, "3");

				//connect to db
				if (!pDBC->IsOpen())
				{
					pDBC->Connect("127.0.0.1", "mydatabase", "root", "123456", "UTF-8", 3306);
				}
				if (pDBC->IsOpen())
				{
					
					//create table
					if (!pDBC->IsTableExist("TEST2"))
					{
						const char * cMysql1 = "CREATE TABLE TEST2(ID INT(8) PRIMARY KEY, NAME VARCHAR(16) );";
						pDBC->Execute(cMysql1);
					}
					
					//excute sql for insert
					const char * cMysql2 = "INSERT INTO TEST2 VALUES (1, 'BBB');";
					pDBC->Execute(cMysql2);

					Sleep(1);
					
					//excute sql for query
					const char * cMysql3 = "SELECT * FROM TEST2;";
					IRecordSet * pRec = pDBC->Query(cMysql3);

					//trvaversal the result record.
					pRec->MoveFirst();
					while (!pRec->IsEOF())
					{
						FString getValue = pRec->GetStringValue(pRec->GetFieldName(1)).c_str();

						getValue += " *****";
						GLog->Log(getValue);
						GEngine->AddOnScreenDebugMessage(-1, -1, FColor::Green, getValue);

						pRec->MoveNext();
					}
					//close the result record.
					pRec->Close();

					//close the db connection.
					pDBC->DisConnect();

				}

			}

		}
	}

ue4-mysqlplugin's People

Contributors

anhanjinj avatar

Stargazers

richmondx avatar

Watchers

James Cloos avatar richmondx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.