主要类说明
SAConnection 连接
SACommand 命令
eSAClient 数据库类型的枚举类
连接数据库
SAConnection m_db_connection;
SACommand m_db_command;
m_db_connection.Connect(database.c_str(), user.c_str(), password.c_str(), eSAClient.SA_MySQL_Client);
m_db_command.setConnection(&m_db_connection);
参数说明:
database,数据库名称,格式为 [ip:port@]database_name
user,数据库用户名
password,密码
eSAClient,所要连接的数据库类型,默认值为SA_Client_NotSpecified
Select,查询操作
增、删、改、查用到的类都是SACommand类。
对于查询操作,步骤是,先设置好sql语句,然后执行,最后获取结果。
// 设置sql语句
m_db_command.setCommandText(sql.c_str());
// 执行命令
m_db_command.Execute();
// 获取