hehe
解决方案 »
- 【求助】mysql 无法插入中文内容的问题
- mysql 安装问题
- mysql中三张表建立触发器问题
- 求一个mysql的sql语句最优写法
- 在mysql中如何做到当多个人操作一个表时,只允许某一个人操作?
- MySQL怎样删除索引
- MySQL 和 PostgreSQL 是否能支持 connect by prior ... start with ...
- 如何将oracle数据库中的表转换(导入)mysql数据库??请指点!
- 为何GROUP BY加上索引更慢呢?
- 如何显示回复用户的名字
- 請幫忙!delphi連結MySql提示“DBX Error: Invalid Precision.”
- Mysql中tuncate中一个奇怪的问题
CREATE TABLE `bbs`.`codes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(11) DEFAULT NULL,
`topic` mediumtext NOT NULL,
`content` longtext NOT NULL,
`timer` datetime NOT NULL,
`publisher` varchar(45) NOT NULL,
`hits` int(10) unsigned NOT NULL,
`categoryid` varchar(45) NOT NULL,
`classid` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=gb2312 COMMENT='InnoDB free: 8192 kB';
int main(int argc, char *argv[])
{
// Get database access parameters from command line
const char* db = "bbs", *server = "localhost", *user = "root", *pass = "admin";
// Connect to the sample database.
mysqlpp::Connection conn(false);
if (conn.connect(db, server, user, pass)) {
// Retrieve a subset of the sample stock table set up by resetdb
// and display it.
mysqlpp::Query query(&conn,false,"select topic from codes");
if (mysqlpp::StoreQueryResult res = query.store()) {
cout << "We have:" << endl;
for (size_t i = 0; i < res.num_rows(); ++i) {
cout << '\t' << res[i][0] << endl;
}
}
else {
cerr << "Failed to get item list: " << query.error() << endl;
return 1;
} return 0;
}
else {
cerr << "DB connection failed: " << conn.error() << endl;
return 1;
}
}