User Tools

Site Tools


c:mysql:mysql.h:mysql_autocommit

Differences

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

Link to this comparison view

c:mysql:mysql.h:mysql_autocommit [2013/02/03 20:19]
127.0.0.1 external edit
c:mysql:mysql.h:mysql_autocommit [2024/02/16 01:12] (current)
Line 1: Line 1:
 ====== mysql_autocommit ====== ====== mysql_autocommit ======
 <code c> <code c>
 +my_bool mysql_autocommit(MYSQL *mysql, my_bool mode)
 </code> </code>
  
 ==== description of mysql_autocommit ==== ==== description of mysql_autocommit ====
-mysql_autocommit is in work by code-reference.com \\  +mysql_autocommit set the autocommit\\ 
-if you are faster... don't hasitate and add it+is off\\ 
 +1 is on\\
  
 +
 +compile with gcc mysql_autocommit.c -o mysql_autocommit `mysql_config –cflags –libs` -Wall 
 <code c> <code c>
-no example at the moment +#include <stdio.h> /* including standard library */  
-</code>+#include <mysql/mysql.h> 
 +  
 +MYSQL *my; 
 +MYSQL_ROW  row; 
 +MYSQL_RES  *mysql_res;  
 + 
 +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"); // select DB 
 + 
 +  
 +  mysql_autocommit(my, 1);    // set autocommit to ON 
 +   
 +  mysql_query(my, "SELECT @@autocommit"); 
 +   
 +  mysql_res = mysql_store_result(my); 
 +  row = mysql_fetch_row (mysql_res);   // fetch the result 
 +  printf("autocommit is: %s\n" 
 +         "0 = off\n1 = on\n", row[0]); 
 + 
 + 
 +mysql_close(my); 
 +return 0; 
 +}</code>
  
 ===== output of mysql_autocommit c example ===== ===== output of mysql_autocommit c example =====
-    no example at the moment+    Login correct 
 +    autocommit is: 1 
 +    0 = off 
 +    1 = on
  

on the occasion of the current invasion of Russia in Ukraine

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

Impressum Datenschutz