If you're going to get a book, I'd get one on general SQL. It's a big enough
topic
in and of itself, and the MySQL C API isn't all that complicated.
Personally I think books are too expensive :) There are a lot of good
resources on
the 'net and a lot of people on this list who have messed around with it before.
BTW.. I wrote this a while back, but haven't had a chance to test it.
Ideally I'd like to be able to handle queries in C as easily as they are in the
perl
DBI module. Which means I need a simple way to get results back afterwards also
(values associated with the field name).
bool mysql_queryf(MYSQL *mysql, char *fmt, ...)
{
int querylen = strlen(fmt)+1, iarg;
va_list args;
char *query = (char *)malloc(querylen), *qp = query, *carg;
// I've found it's good to ping the server to make sure you have a connection
if (mysql_ping(mysql))
return FALSE;
va_start(args, fmt);
for (; *fmt; fmt++)
{
if (*fmt == '%')
switch(*(++fmt))
{
case '%':
*(qp++) = '%';
break;
case 's':
carg = va_arg(args, char *);
query = (char *)realloc(query, querylen += strlen(carg));
qp += mysql_real_escape_string(mysql, qp, carg, strlen(carg));
break;
case 'd':
iarg = va_arg(args, int);
query = (char *)realloc(query, querylen += 16);
qp += sprintf(qp, "%d", iarg);
break;
}
else
*(qp++) = *fmt;
}
va_end(args);
*qp = '\0';
querylen = mysql_real_query(mysql, query, qp-query);
free(query);
return querylen;
}
----- Original Message -----
From: "Dale Kingston" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, March 11, 2004 1:42 AM
Subject: Kind of off topic
> Ok have a question but this is more on advise then pretaning to rom... But I
> want to start using SQL with the mud. Been hearing alot that alot of muds
> have started to switch over to like SQL or XML as things to save their
> pfiles and that in. And I was wondering if anyone had a suggestion on a good
> MySQL book to get. Hehehehe I was going to get the one for dummies but IDK
> if that one will cover all my needs.
>
> Also if you've already switch, maybe a small bit of advice on maybe
> something not to do. Thanks for your time :)
>
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom