====== mysql_info ======
const char *mysql_info(MYSQL *mysql)
==== description of mysql_info ====
A character string containing additional information about the most recent query. NULL if no information about the request are available.
compile with gcc mysql_info.c -o mysql_info `mysql_config –cflags –libs` -Wall
#include /* including standard library */
#include
MYSQL *my;
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, "INSERT INTO `test`.`collection`"
" (`id`, `name`, `title`, `published`)"
" VALUES (NULL, 'Demian', 'Debian 6.0', '2013-02-14');");
printf("MySQL Info: %s\n", mysql_info(my));
mysql_query(my, "UPDATE `test`.`collection`"
" SET name = 'Debian'"
" WHERE `name` LIKE 'Demian';");
printf("MySQL Info: %s\n", mysql_info(my));
mysql_close(my);
return 0;
}
=== db for this mysql_info example===
--
-- Database: `test`
--
CREATE DATABASE `test` DEFAULT CHARACTER SET latin1 COLLATE utf8_general_ci;
USE `test`;
-- --------------------------------------------------------
--
-- Tablestructure for Table `collection`
--
CREATE TABLE IF NOT EXISTS `collection` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(90) NOT NULL,
`title` varchar(255) NOT NULL,
`published` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
===== output of mysql_info c example =====
Login correct
MySQL Info: (null)
MySQL Info: Rows matched: 1 Changed: 1 Warnings: 0