User Tools

Site Tools


c:mysql:mysql.h:mysql_fetch_fields

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:mysql:mysql.h:mysql_fetch_fields [2013/02/25 23:36]
Daniel Gohlke
c:mysql:mysql.h:mysql_fetch_fields [2024/02/16 01:12] (current)
Line 5: Line 5:
  
 ==== description of mysql_fetch_fields ==== ==== description of mysql_fetch_fields ====
-mysql_fetch_fields is in work by code-reference.com \\  +mysql_fetch_fields provides an array of information about the fields in a amount of result
-if you are faster... don't hasitate and add it+
  
 <code c> <code c>
-no example at the moment+#include <stdio.h> /* including standard library */  
 +#include <mysql/mysql.h> 
 +  
 +MYSQL *my; 
 +MYSQL_RES *result; 
 +MYSQL_FIELD *fields; 
 + 
 +int main( void ) 
 +
 + 
 +char host[20]; 
 +char user[20]; 
 +char pass[20]; 
 + 
 +my = mysql_init(NULL); 
 + 
 +sprintf(host,"localhost"); 
 +sprintf(user,"username"); 
 +sprintf(pass,"password"); 
 +  
 +if (my == NULL ) { 
 +printf("Cant initalisize MySQL\n"); 
 +return 1; 
 +
 +  
 +if( mysql_real_connect (my,host,user,pass,NULL,0,NULL,0)  == NULL) { 
 +  printf("Error cant login\n"); 
 +  } else { 
 +  printf("Login correct\n"); 
 +  } 
 + 
 + 
 +mysql_select_db(my, "test"); 
 + 
 +mysql_query(my, "SELECT * FROM collection LIMIT 1;"); 
 +result = mysql_store_result( my ); 
 + 
 +fields = mysql_fetch_fields(result); 
 + 
 +  printf("name %s \t\t", fields->name); 
 +  printf("name_length: %i\n", fields->name_length); 
 + 
 +/* 
 +  printf("fields->org_name %s\n", fields->org_name); 
 +  printf("fields->org_name_length %i\n", fields->org_name_length); 
 + 
 +  printf("fields->table %s\n", fields->table); 
 +  printf("fields->table_length %i\n", fields->table_length); 
 + 
 +  printf("fields->org_table %s\n", fields->org_table); 
 +  printf("fields->org_table_length %i\n", fields->org_table_length); 
 + 
 +  printf("fields->db %s\n", fields->db); 
 +  printf("fields->db_length %i\n", fields->db_length); 
 + 
 +  printf("fields->catalog %s\n", fields->catalog); 
 +  printf("fields->catalog_length %i\n", fields->catalog_length); 
 + 
 +  printf("fields->def %s\n", fields->def); 
 +  printf("fields->def_length %i\n", fields->def_length); 
 + 
 +  printf("fields->length %li\n", fields->length); // unsigned long 
 +  printf("fields->max_length %li\n", fields->max_length); // unsigned long 
 + 
 +  printf("fields->flags %u\n", fields->flags); // unsigned long 
 +*/ 
 + 
 + 
 +mysql_close(my); 
 +return 0; 
 +}
 </code> </code>
  
 ===== output of mysql_fetch_fields c example ===== ===== output of mysql_fetch_fields c example =====
-    no example at the moment +    Login correct 
 +    name id            name_lenght: 2

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/mysql/mysql.h/mysql_fetch_fields.txt · Last modified: 2024/02/16 01:12 (external edit)

Impressum Datenschutz