Not exactly sure where to put this so i put it here... I'm looking to learn C++ and Mysql and how to use the two together... I was just wondering maybe which books might be of interest or any webpages or the like, any thing really would help. Thank you.
C++ and Mysql
Posted by Metsuro on Sat 26 Aug 2006 01:46 AM — 16 posts, 78,241 views.
I dunno about mysql, but I learned C++ using Sam's "Teach Yourself C++ in 21 days". Sure enough, I learned enough C++ to do what I need with it...
It doesn't go very in depth on the language but it's definately a way to start yourself off.
It doesn't go very in depth on the language but it's definately a way to start yourself off.
I just saw something about this. Uhh, a snippet I think. I thought it was on MudBytes but I cannot seem to find it.
Its a discussion about adding mysql support to smaug on smuagfuss.org. But I want to start over from scratch creating a new start using sql, but I just want to learn about using the two and maybe try using it with my smaugfuss mud, and just test around yea know?
and I have thought about using tinymud or which ever the one nick made, however I cant ever seem to get it to compile the way it is.
TinyMUD didn't use mysql, but it had C++ in it from memory.
I found the MySQL reference manual by Paul DuBois quite helpful.
# Paperback: 1320 pages
# Publisher: Sams; 3 edition (March 8, 2005)
# Language: English
# ISBN: 0672326736
I had an earlier edition, but it explains about using MySQL in general and the interfaces in various languages, such as PHP, C etc.
I found the MySQL reference manual by Paul DuBois quite helpful.
# Paperback: 1320 pages
# Publisher: Sams; 3 edition (March 8, 2005)
# Language: English
# ISBN: 0672326736
I had an earlier edition, but it explains about using MySQL in general and the interfaces in various languages, such as PHP, C etc.
Here are some tutorials:
http://www.cplusplus.com/doc/
http://www.cprogramming.com/tutorial.html#ctutorial
(C++ isn't a whole lot different from C)
http://dev.mysql.com/doc/mysql/en/index.html
http://dev.mysql.com/doc/refman/5.0/en/tutorial.html
http://www.cplusplus.com/doc/
http://www.cprogramming.com/tutorial.html#ctutorial
(C++ isn't a whole lot different from C)
http://dev.mysql.com/doc/mysql/en/index.html
http://dev.mysql.com/doc/refman/5.0/en/tutorial.html
well I knew it didn't have it, but i want to make a codebase using C++ not C, however I've never been able to get tinymud to work as is in the shell I had...
Isn't Dawn of Time C++? And has some sql stuff too?
No. Dawn has no SQL support in it. It looks like there was a discussion about that 3 years ago but the thread turned into one of those stupid political "pgsql is better than mysql" things and it doesn't look like anyone responded after that.
I'm mostly interested in just figuring out how to get the basics like tinymud has done, for like connecting to the mud, and then have mysql work for alot of the other things I wish. I orginally wanted just to work with Tinymud and start from there, but I couldn't get it to compile and didn't think of asking for help on it heh.
It should compile. Can you post your error messages? Did you use Cygwin or directly on Linux?
I used linux, from my shell its like fedora core 4, but I cant use the shell because the bill is late, so once I can pay the bill I'll test it.
If you're looking for C++/MySQL, and check out the MySQL C api, consider using a third party C++ wraper for it. http://tangentsoft.net/mysql++/ is the only one I know of (and you can find the link to it via mysql development site). It says it's based of STL principals so you'd have to pick up the basics of STL, which some C++ books cover. If you don't feel the need to buy a book, then look no farther than this site! Probably 70% of my knowledge of STL is derived from this site! The other is reading docs and experimenting. You can thank Nick for the wonderful resource! Also, once you pick up the basics of C++, check out Stroustrup's book on C++. Wonderful reference and tool. Also, I have a very premature C++ MUD with a bunch of odd MySQL stuff. It doesn't use mysql++, it's my own doing ;). alhaen.gfys.ca/alhaen.tar.gz check it out, it'll probably confuse you at first, then once you know C++ you'll realize how bad some of it is, heh :).
Davion
Davion
player.cpp:
void Player::Create()
{ String query;
query << "INSERT INTO `Players` VALUES()";
query.Query();
query.Empty();
query << "SELECT * FROM `Players` ORDER BY id DESC limit 1";
MYSQL_RES *rez;
if( !( rez = query.Query() ) )
{ Logs::cout << "Player::Create: Select statement empty!" << Logs::endl;
return;
}
MYSQL_ROW row = mysql_fetch_row(rez);
SetId(atoi(row[0]) );
mysql_free_result(rez);
Save();
}
lol shouldnt all that just use mysql_insert_id :/
void Player::Create()
{ String query;
query << "INSERT INTO `Players` VALUES()";
query.Query();
query.Empty();
query << "SELECT * FROM `Players` ORDER BY id DESC limit 1";
MYSQL_RES *rez;
if( !( rez = query.Query() ) )
{ Logs::cout << "Player::Create: Select statement empty!" << Logs::endl;
return;
}
MYSQL_ROW row = mysql_fetch_row(rez);
SetId(atoi(row[0]) );
mysql_free_result(rez);
Save();
}
lol shouldnt all that just use mysql_insert_id :/
I'd argue Postgres over MySQL, but rather let's cut to the chase or the root of the problem. Using MySQL with the default storage backend MyISAM is an accident just waiting to happen as it is not ACID compliant. Override the defaults and use the InnoDB as the backend for MySQL. I think there's a storage parameter on CREATE TABLE DDL. MyISAM storage can be very easily corrupted if the server is killed for any reason, signal or power outage. InnoDB is immune to such corruption and is of necessity slightly slower because it journals, a good thing, but you'll not notice it.
I'm using Sqlite. http://sqlite.org
SQLite is also not a "real" rdbms as it don't support many of the necessary relational algebras such as constraints and schema alter very well. However, it is ACID compliant and can be nicely embedded in a server without any need for administrative (root) permissions.
Watch for the next release of Murk++. ;-)
Here's another tutorial on it:
http://docs.cs.byu.edu/docs/sqlite/index.php
Also Postgres supports GIS databases with spatial query language additions. The usefulness of this for roomless muds has yet to be explored AFAIK. There was a discussion on GIS over on the MudLab forum. Do a search on GIS over there if it's of interest. :-)
I'm using Sqlite. http://sqlite.org
SQLite is also not a "real" rdbms as it don't support many of the necessary relational algebras such as constraints and schema alter very well. However, it is ACID compliant and can be nicely embedded in a server without any need for administrative (root) permissions.
Watch for the next release of Murk++. ;-)
Here's another tutorial on it:
http://docs.cs.byu.edu/docs/sqlite/index.php
Also Postgres supports GIS databases with spatial query language additions. The usefulness of this for roomless muds has yet to be explored AFAIK. There was a discussion on GIS over on the MudLab forum. Do a search on GIS over there if it's of interest. :-)