本文整理汇总了C++中Database::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::Initialize方法的具体用法?C++ Database::Initialize怎么用?C++ Database::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::Initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
int initialize(lua_State* state)
{
Database* mysqldb = makeDatabase(state);
if (!mysqldb) return 0;
std::string error;
if (!mysqldb->Initialize(error))
{
LUA->PushBool(false);
LUA->PushString(error.c_str());
delete mysqldb;
return 2;
}
UserData* userdata = (UserData*)LUA->NewUserdata(sizeof(UserData));
userdata->data = mysqldb;
userdata->type = DATABASE_ID;
int uData = LUA->ReferenceCreate();
LUA->ReferencePush(iRefDatabases);
LUA->PushNumber(mysqldb->GetTableIndex());
LUA->ReferencePush(uData);
LUA->SetTable(-3);
LUA->ReferencePush(uData);
LUA->ReferenceFree(uData);
LUA->CreateMetaTableType(DATABASE_NAME, DATABASE_ID);
LUA->SetMetaTable(-2);
return 1;
}
示例2: 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;
}
示例3: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
Log.loglevel = 999;
const char * username = "";
const char * password = "";
const char * dbname = "";
if(!sDatabase.Initialize("localhost", 3306, username, password, dbname, 1, 65536))
{
Log.Error("SQL", "could not connect");
return 1;
}
QueryResult * result = sDatabase.Query("SELECT guid, skills FROM characters");
do
{
char * skills = strdup(result->Fetch()[1].GetString());
if(strchr(skills, ',') != 0)
{
// need to convert
uint32 i = 0;
stringstream ss;
char * start = skills;
char * end;
for(;;)
{
// skill, skill+1, <add>0
end = strchr(start, ',');
if(!end)
break;
*end = '\0';
uint32 val = atoi(start);
start = end + 1;
ss << val << " ";
++i;
if(!(i % 2))
ss << "0 ";
}
sDatabase.Execute("UPDATE characters SET skills = '%s' WHERE guid = %u", ss.str().c_str(), result->Fetch()[0].GetUInt32());
Log.Debug("SQL", "UPDATE characters SET skills = '%s' WHERE guid = %u", ss.str().c_str(), result->Fetch()[0].GetUInt32());
}
} while(result->NextRow());
delete result;
sDatabase.Shutdown();
Log.Success("Program", "Exit normally");
return 0;
}
示例4: main
int main(int argc, char* argv[])
{
std::string map;
std::string style;
glutInit(&argc, argv); // Initialize GLUT
if (argc!=3) {
std::cerr << "DrawMap <map directory> <style-file>" << std::endl;
return 1;
}
map=argv[1];
style=argv[2];
if (!database.Initialize(map,
style)) {
std::cerr << "Cannot open database" << std::endl;
}
drawParameter.SetDrawWaysWithFixedWidth(false);
drawParameter.SetRenderSeaLand(true);
drawParameter.SetDebugPerformance(true);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA);
glutInitWindowSize(width, height); // Set the window's initial width & height
glutInitWindowPosition(50, 50); // Position the window's initial top-left corner
window=glutCreateWindow("DrawMapOpenGL"); // Create a window with the given title
glutDisplayFunc(OnDisplay); // Register display callback handler for window re-paint
glutKeyboardFunc(OnKeyPressed); // Keyboard handling
glutReshapeFunc(OnResize);
OnInit();
glutMainLoop(); // Enter the event-processing loop
return 0;
}