免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2627 | 回复: 0
打印 上一主题 下一主题

MYSQL 数据结构 和MYSQL_RES [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-23 10:46 |只看该作者 |倒序浏览

                以下代码块是用来连接数据库的通讯过程,要连接MYSQL,必须建立MYSQL实例,通过mysql_init初始化方能开始进行连接.typedef struct st_mysql {  NET           net;            /* Communication parameters */  gptr          connector_fd;   /* ConnectorFd for SSL */  char          *host,*user,*passwd,*unix_socket,                *server_version,*host_info,*info,*db;  unsigned int  port,client_flag,server_capabilities;  unsigned int  protocol_version;  unsigned int  field_count;  unsigned int  server_status;  unsigned long thread_id;      /* Id for connection in server */  my_ulonglong affected_rows;  my_ulonglong insert_id;       /* id if insert on table with NEXTNR */  my_ulonglong extra_info;              /* Used by mysqlshow */  unsigned long packet_length;  enum mysql_status status;  MYSQL_FIELD   *fields;  MEM_ROOT      field_alloc;  my_bool       free_me;        /* If free in mysql_close */  my_bool       reconnect;      /* set to 1 if automatic reconnect */  struct st_mysql_options options;  char          scramble_buff[9];  struct charset_info_st *charset;  unsigned int  server_language;} MYSQL;
这个结构代表返回行的一个查询的(SELECT, SHOW, DESCRIBE, EXPLAIN)的结果。返回的数据称为“数据集”,用过数据库的朋友应该对数据库中查询后得到的结果集不会陌生,在C的API里对应的就是MYSQL_RES了,从数据库读取数据,最后就是从MYSQL_RES中读取数据。
typedef struct st_mysql_res {  my_ulonglong row_count;  unsigned int  field_count, current_field;  MYSQL_FIELD   *fields;  MYSQL_DATA    *data;  MYSQL_ROWS    *data_cursor;  MEM_ROOT      field_alloc;  MYSQL_ROW     row;            /* If unbuffered read */  MYSQL_ROW     current_row;    /* buffer to current row */  unsigned long *lengths;       /* column lengths of current row */  MYSQL         *handle;        /* for unbuffered reads */  my_bool       eof;            /* Used my mysql_fetch_row */} MYSQL_RES;
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/73525/showart_2100883.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP