User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:mysql:mysql.h:mysql_fetch_fields

mysql_fetch_fields

description of mysql_fetch_fields

mysql_fetch_fields provides an array of information about the fields in a amount of result

#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;
}

output of mysql_fetch_fields c example

  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