VC9, MySQL5.1我用MySQL的C API, 使用MYSQL_ROW row = mysql_fetch_row(query)子后才发现,row里面的保存的是字符数组。
我就很不明白了,比如一个INT字段在数据库中用4个字节保存整数,调用mysql_fetch_row()的过程中,还要进行Int to char*的转换。而在我的使用中,又要把它还原成Int,这样,中间就有两次白白的转换。
请问有没有直接读取出字段原来类型的API?谢谢
我就很不明白了,比如一个INT字段在数据库中用4个字节保存整数,调用mysql_fetch_row()的过程中,还要进行Int to char*的转换。而在我的使用中,又要把它还原成Int,这样,中间就有两次白白的转换。
请问有没有直接读取出字段原来类型的API?谢谢
解决方案 »
- mysql多表联合查询并排序问题
- 有关数据库的问题,憋了很久了,求大神指导啊
- mysql 存储过程 怎么比较数据库里面记录的日期,是不是和当前日期相同
- 添加外键约束失败!
- Mysql 执行时间
- mysql存储过程数据引起的死循环如何定位
- 请问MYSQL有没有不输出query结果只输出query执行时间的方法?
- grant all on mysql.* to name@% ERROR!
- 汇总统计SQL请教
- mysql数据库没有备份就进行替换。但替换的人说mysql数据库替换前,已经把它先放到回收站里了,然后才进行替换。如果想还原,可以用回收站里的mysql数据库进
- mysql触发器和定时器混用发生错误
- 关于mysql导出xml文件
// 加载mysqldb类
require_once('./mysqldb.php');
$db = new mysqldb();
$mysqli = &$db->getMysqli();
$sqlquery ="select id,name,startdate,uptime,regtime from test.t1";
// Send a query to the server
if ($result = $mysqli->query($sqlquery)) {
if($result->num_rows > 0){
if($row = $result->fetch_array(MYSQLI_BOTH)) {
print_r($row);
echo "id ->".gettype($row[0])."\n";
echo "name ->".gettype($row[1])."\n";
echo "startdate ->".gettype($row[2])."\n";
echo "uptime ->".gettype($row[3])."\n";
echo "regtime ->".gettype($row[4])."\n";
}
}
}
// Destroy the result set and free the memory used for it
if($result) $result->close();
$db->close();
exit;
?>php tmp.php
Array
(
[0] => 1
[id] => 1
[1] => coolwind
[name] => coolwind
[2] => 2009-05-01
[startdate] => 2009-05-01
[3] => 2009-05-19 08:10:32
[uptime] => 2009-05-19 08:10:32
[4] => 2009-05-19 08:10:32
[regtime] => 2009-05-19 08:10:32
)
id ->string
name ->string
startdate ->string
uptime ->string
regtime ->string