当前位置: 首页>>代码示例>>C++>>正文


C++ Database::IsConnected方法代码示例

本文整理汇总了C++中Database::IsConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::IsConnected方法的具体用法?C++ Database::IsConnected怎么用?C++ Database::IsConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database::IsConnected方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DBConnect

int DBConnect(lua_State* state)
{
	LUA->CheckType(1, DATABASE_ID);

	Database * mysqldb = *reinterpret_cast<Database **>(LUA->GetUserdata(1));

	if (!mysqldb) {
		LUA->ThrowError("Attempted to call Connect on a shutdown database");
		return 0;
	}

	if (mysqldb->IsConnected()) {
		LUA->ThrowError("Attempted to call Connect on an already connected database");
		return 0;
	}

	std::string error;
	bool success = mysqldb->Initialize(error);

	LUA->PushBool(success);

	if (!success)
	{
		LUA->PushString(error.c_str());
		delete mysqldb;
		return 2;
	}
	return 1;
}
开发者ID:TeddiO,项目名称:gm_tmysql4,代码行数:29,代码来源:gm_tmysql.cpp

示例2: DBEscape

int DBEscape(lua_State* state)
{
	LUA->CheckType(1, DATABASE_ID);

	Database * mysqldb = *reinterpret_cast<Database **>(LUA->GetUserdata(1));

	if (!mysqldb) {
		LUA->ThrowError("Attempted to call Escape on a shutdown database");
		return 0;
	}

	if (!mysqldb->IsConnected()) {
		LUA->ThrowError("Attempted to call Escape on a disconnected database");
		return 0;
	}

	LUA->CheckType(2, Type::STRING);

	unsigned int len;
	const char* query = LUA->GetString(2, &len);

	char* escaped = mysqldb->Escape(query, len);
	LUA->PushString(escaped);

	delete[] escaped;
	return 1;
}
开发者ID:TeddiO,项目名称:gm_tmysql4,代码行数:27,代码来源:gm_tmysql.cpp

示例3: DBIsConnected

int DBIsConnected(lua_State* state)
{
	LUA->CheckType(1, DATABASE_ID);

	Database * mysqldb = *reinterpret_cast<Database **>(LUA->GetUserdata(1));

	if (!mysqldb) {
		LUA->ThrowError("Attempted to call IsConnected on a shutdown database");
		return 0;
	}

	LUA->PushBool(mysqldb->IsConnected());
	return 1;
}
开发者ID:TeddiO,项目名称:gm_tmysql4,代码行数:14,代码来源:gm_tmysql.cpp

示例4: DBGetServerVersion

int DBGetServerVersion(lua_State* state)
{
	LUA->CheckType(1, DATABASE_ID);

	Database * mysqldb = *reinterpret_cast<Database **>(LUA->GetUserdata(1));

	if (!mysqldb) {
		LUA->ThrowError("Attempted to call GetServerVersion on a shutdown database");
		return 0;
	}

	if (!mysqldb->IsConnected()) {
		LUA->ThrowError("Attempted to call GetServerVersion on a disconnected database");
		return 0;
	}

	LUA->PushNumber(mysqldb->GetServerVersion());
	return 1;
}
开发者ID:TeddiO,项目名称:gm_tmysql4,代码行数:19,代码来源:gm_tmysql.cpp

示例5: main

int main()
{

    ServerSocket sSocket(15780);
    printf("   Server Online....!! \n");
    if(db.IsConnected())
    {
        while(true)
        {
            SOCKET s = sSocket.Accept();
            printf("Accepted connection...\n");
            CreateThread(0, 0, (LPTHREAD_START_ROUTINE)GameSocket::ReceiveThread, &s, 0, 0);
        }
    }
    else
    {
        printf("Connection with database failed.\n");
        return 1;
    }
    return 0;
}
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:21,代码来源:GameServer.cpp

示例6: DBSetCharacterSet

int DBSetCharacterSet(lua_State* state)
{
	LUA->CheckType(1, DATABASE_ID);

	Database * mysqldb = *reinterpret_cast<Database **>(LUA->GetUserdata(1));

	if (!mysqldb) {
		LUA->ThrowError("Attempted to call SetCharacterSet on a shutdown database");
		return 0;
	}

	if (!mysqldb->IsConnected()) {
		LUA->ThrowError("Attempted to call SetCharacterSet on a disconnected database");
		return 0;
	}

	const char* set = LUA->CheckString(2);

	std::string error;
	LUA->PushBool(mysqldb->SetCharacterSet(set, error));
	LUA->PushString(error.c_str());
	return 2;
}
开发者ID:TeddiO,项目名称:gm_tmysql4,代码行数:23,代码来源:gm_tmysql.cpp

示例7: DBQuery

int DBQuery(lua_State* state)
{
	LUA->CheckType(1, DATABASE_ID);

	Database * mysqldb = *reinterpret_cast<Database **>(LUA->GetUserdata(1));

	if (!mysqldb) {
		LUA->ThrowError("Attempted to call Query on a shutdown database");
		return 0;
	}

	if (!mysqldb->IsConnected()) {
		LUA->ThrowError("Attempted to call Query on a disconnected database");
		return 0;
	}

	const char* query = LUA->CheckString(2);

	int callbackfunc = -1;
	if (LUA->GetType(3) == Type::FUNCTION)
	{
		LUA->Push(3);
		callbackfunc = LUA->ReferenceCreate();
	}

	int callbackref = -1;
	int callbackobj = LUA->GetType(4);
	if (callbackobj != Type::NIL)
	{
		LUA->Push(4);
		callbackref = LUA->ReferenceCreate();
	}

	mysqldb->QueueQuery(query, callbackfunc, callbackref, LUA->GetBool(5));
	return 0;
}
开发者ID:TeddiO,项目名称:gm_tmysql4,代码行数:36,代码来源:gm_tmysql.cpp


注:本文中的Database::IsConnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。