[ Date Index ][
Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]
On Thursday 10 April 2003 3:28 pm, Andrew Rogers wrote: > I'm looking for a very short MySQL example written in C and using the > MySQL C API and mysql.h include file. I have started learning MySQL this This can't be too far from the mark: http://www.mysql.com/documentation/mysql/bychapter/index.html#libmysqld_example This example program and makefile should work without any changes on a Linux or FreeBSD system. For other operating systems, minor changes will be needed. This example is designed to give enough details to understand the problem, without the clutter that is a necessary part of a real application. To try out the example, create an `test_libmysqld' directory at the same level as the mysql-4.0 source directory. Save the `test_libmysqld.c' source and the `GNUmakefile' in the directory, and run GNU `make' from inside the `test_libmysqld' directory Even if you don't compile the example, the only include files are: #include <mysql.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> and uses very simple prototypes: MYSQL *db_connect(const char *dbname); void db_disconnect(MYSQL *db); void db_do_query(MYSQL *db, const char *query); That's about as close to Perl as I've seen C ever get! Even PHP uses the same basic functions. The rest of the FAQ deals with the details of the function calls in the usual manual-babble way. -- Neil Williams ============= http://www.codehelp.co.uk http://www.dclug.org.uk http://www.wewantbroadband.co.uk/
Attachment:
pgp00014.pgp
Description: signature