資源簡介
一個mysql的c++封裝類 方便各種開發,是mysql調用變得簡便
代碼片段和文件信息
#include?“DBMysql.h“
#include?
/*構造函數,設定連接的服務器,用戶名,密碼和端口*/
DBMysql::DBMysql(string?hoststring?userstring?passwordunsigned?int?port=3306)
{
?mysql?=?mysql_init(NULL);
?num?=?0;
?error=““;
?query=““;
?result?=?NULL;
?SetConnect(hostuserpasswordport);
}
DBMysql::DBMysql()
{
}
/*設定連接的服務器,用戶名,密碼和端口*/
void?DBMysql::SetConnect(string?hoststring?userstring?passwordunsigned?int?port)
{
?DBMysql::host?=?host;
?DBMysql::user?=?user;
?DBMysql::password?=?password;
?DBMysql::port?=?port;
}
/*連接數據庫*/
unsigned?int?DBMysql::DBConnect()
{
?MYSQL?*con;
?if(mysql?==?NULL)
?{
??error?=?“初始化mysql錯誤“;
??return?1;
?}
?con?=?mysql_real_connect(mysqlhost.c_str()user.c_str()password.c_str()NULLportNULL0);
?if(con?==?NULL)
?{
??error=mysql_error(mysql);
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4966??2009-11-05?20:46??mysql_CPP\DBMysql.cpp
?????文件???????1819??2009-11-05?20:45??mysql_CPP\DBMysql.h
?????文件???????1916??2011-11-18?02:33??mysql_CPP\main.cpp
?????文件???????3468??2011-11-18?02:33??mysql_CPP\main.dsp
?????文件????????531??2009-11-05?20:53??mysql_CPP\main.dsw
?????文件??????33792??2011-11-18?02:33??mysql_CPP\main.ncb
?????文件??????48640??2011-11-18?02:33??mysql_CPP\main.opt
?????文件????????925??2011-11-18?02:33??mysql_CPP\main.plg
?????文件????????873??2011-08-04?01:18??mysql_CPP\main.sln
????..A..H.?????17408??2011-11-17?23:18??mysql_CPP\main.suo
?????文件???????5362??2011-08-04?01:20??mysql_CPP\main.vcproj
?????文件???????1405??2011-08-09?11:23??mysql_CPP\main.vcproj.VKIN.mry.user
?????文件????????182??2009-11-05?20:57??mysql_CPP\編譯方法.txt
?????文件????1470464??2006-05-26?04:50??mysql_CPP\Release\libmysql.dll
?????目錄??????????0??2011-12-17?21:03??mysql_CPP\Release
?????目錄??????????0??2011-12-17?21:03??mysql_CPP
-----------?---------??----------?-----??----
??????????????1591751????????????????????16
- 上一篇:MPI并行程序設計都志輝-C源程序
- 下一篇:淺析C++類的底層實現
評論
共有 條評論