本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}