mysqli.cpp

来自「仿照php的mysqli扩展自己使用MySQL的C Interface实现了一个」· C++ 代码 · 共 50 行

CPP
50
字号
#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));	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?