#include "MySQLi.h"
MySQLi::MySQLi(std::string hostname, std::string username, std::string password, std::string dbname, unsigned int port=3306)
{
this->m_hostname = hostname;
this->m_username = username;
this->m_password = password;
this->m_dbname = dbname ;
this->m_port = port ;
//this->m_unix_socket = unix_socket;
//this->m_client_flag = client_flag;
this->mysql_conn = mysql_init(NULL);
mysql_real_connect(
this->mysql_conn,
(this->m_hostname).c_str(),
(this->m_username).c_str(),
(this->m_password).c_str(),
(this->m_dbname).c_str(),
this->m_port,
(this->m_unix_socket).c_str(),
this->m_client_flag
);
}
MySQLi::~MySQLi()
{
if (this->mysql_conn)
mysql_close(this->mysql_conn);
}
void MySQLi::close()
{
mysql_close(this->mysql_conn);
}
int MySQLi::select_db(std::string dbname)
{
this->m_dbname = dbname;
return mysql_select_db(this->mysql_conn, (this->m_dbname).c_str());
}
MySQLi_Result* MySQLi::query(std::string query)
{
mysql_query(this->mysql_conn, query.c_str());
return new MySQLi_Result(mysql_use_result(this->mysql_conn));
}
没有合适的资源?快使用搜索试试~ 我知道了~
仿照php的mysqli扩展自己使用MySQL的C Interface实现了一个简单的mysql操作类
共23个文件
mk:4个
d:3个
cpp:3个
0 下载量 146 浏览量
2023-08-10
23:24:31
上传
评论
收藏 254KB ZIP 举报
温馨提示
我仿照php的mysqli扩展自己使用MySQL的C Interface实现了一个简单的mysql操作类。这个类可以帮助我更方便地与MySQL数据库进行交互,并且让我更好地理解底层的操作原理。基于这个类,我写了一个简单的字符统计测试代码,它可以对指定的文本进行统计,并输出每个字符出现的次数,帮助我更好地了解字符的使用情况。这个测试代码还可以对文本进行排序,并输出排序后的结果,让我更加深入地了解文本的结构和内容。在这个过程中,我学到了很多关于MySQL和字符统计的知识,也提高了我的编程能力和解决问题的能力。
资源推荐
资源详情
资源评论
收起资源包目录
MySQLCharCount__.zip (23个子文件)
MySQLCharCount__
include
MySQLi_Result.h 331B
MySQLi.cpp 1KB
MySQLi_Result.cpp 423B
config.h 304B
MySQLi.h 625B
.settings
org.eclipse.cdt.core.prefs 109B
org.eclipse.cdt.managedbuilder.core.prefs 1KB
MySQLCharCount.cpp 507B
.cdtbuild 3KB
.project 511B
Debug
makefile 1KB
subdir.mk 683B
include
subdir.mk 786B
MySQLi.o 119KB
MySQLi_Result.d 138B
MySQLi_Result.o 116KB
MySQLi.d 159B
MySQLCharCount.o 109KB
sources.mk 530B
MySQLCharCount 333KB
MySQLCharCount.d 201B
objects.mk 243B
.cdtproject 583B
共 23 条
- 1
资源评论
且行好事莫问前程
- 粉丝: 2w+
- 资源: 443
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功