一、sql语句
sql=select key from table order by id desc limit 0,1;
二、实现代码
代码如下(示例):
1.读取整形数据
int getlastlinedata(std::string const& table,std::strin const & key)
{
std::string sql="select "+key+" from"+table+"order by id desc limit 0,1;";
return execQuery(sql.c_str()).getIntField(key.c_str());
}
2.读取字符串数据
std::string getlastlinedata(std::string const& table,std::strin const & key)
{
std::string sql="select "+key+" from"+table+"order by id desc limit 0,1;";
return execQuery(sql.c_str()).getStringField(key.c_str());
}
总结
注意sql语句空格位置。