MySQL and Bmax
BlitzMax Forums/BlitzMax Programming/MySQL and Bmax
| ||
Hi! I've been using Bmax for some time and now I want to learn how to use it with MySQL. I know a bit of php and stuff but I have no ideea on how to use it with Bmax. So I guess there is a module or something? Oh and must I download MySQL? Is it a server that must be running while I run my program? A good guide to this might be usefoul Thx in advance! :D |
| ||
http://vertex.dreamfall.at/mysql/mysql102.zip Very simple example includet: SuperStrict Framework Vertex.MySQL Import BRL.StandardIO Import BRL.PolledInput Global MySQL : TMySQL Global Query : String Global Result : TMySQLResult Global Row : TMySQLRow ' Connect MySQL = TMySQL.Create("localhost", "root", "secret", "highscore") If Not MySQL Then Print("Error: Can't connect to 'highscore'") End EndIf ' Show all entries ShowAllEntries() Print "" ' Insert 1 Entry Query = "INSERT INTO `scores` "+ .. "(`name`, `points`) "+ .. "VALUES('test', '100')" Result = MySQL.Query(Query) If Not Result Then Print("Error: Query failed") Print(" "+MySQL.GetError()) MySQL.Close() End EndIf Result.Free() ' Show all entries ShowAllEntries() Print "" ' Delete 1 Entry Query = "DELETE FROM `scores` "+ .. "WHERE `name`='test'" Result = MySQL.Query(Query) If Not Result Then Print("Error: Query failed") Print(" "+MySQL.GetError()) MySQL.Close() End EndIf Result.Free() ' Show all entries ShowAllEntries() Print "" Print " -- Ready --" MySQL.Close() End Function ShowAllEntries() Query = "SELECT * FROM `scores`" Result = MySQL.Query(Query) If Not Result Then Print("Error: Query failed") Print(" "+MySQL.GetError()) MySQL.Close() End EndIf Print(String(Result.Rows)+" Entrys:") For Row = EachIn Result Print("Name: "+Row.GetString(0)) Print("Points: "+Row.GetInt(1)) Next Result.Free() End Function The module runs under Linux perfect too. On MySQL I haven't test it. cu olli |
| ||
Hey, what about Brucey's database module? It supports ODBC, MySQL, and SQLite. Get it at http://www.brucey.net |
| ||
Oh and must I download MySQL? Is it a server that must be running while I run my program? It's a server that you need to download, although you can have it running on a completely different PC if you like. Generally, you need at least the Client libraries on your PC (on all OSes) for the Blitz wrapper to plug into. My Database module has been tested on all platforms, and comes fully documented, with examples for each database type. And, unlike any of the other database modules I've come across, BaH.Database also supports the use of Prepared Statements. Depends what you need, of course... and something smaller like Vertex's module might be everything that you need :-) |
| ||
@Brucey, I installed your database & MySQL mod's. When I tried to build test_01.bmx I get the following error: C:/Program Files/BlitzMax/bin/ld.exe: cannot find -lmysql I understand it's happening in common.bmx (from dbMySQL.mod). For the whole day I try to solve this but I have no clue what is going wrong. btw. I installed MySQL Client Libs as you told. |
| ||
I installed MySQL Client Libs as you told. Where to? |
| ||
I ran the MySQL Server 5.0+ Client Libs installer, which installed everything in: C:\Program Files\MySQL\MySQL Server 5.0 There is also a folder called: C:\MySQL InnoDB Datafiles\ |
| ||
@Kistjes you need to install the client/server as well. |
| ||
Installing the server won't solve his linking problem. I never built it on Windows; but if the MySQL clients bring some LIB files with them, try copying them to the source directory of the mod. Copying the .DLL files there might also help. Like I've said, I never tried building it on Windows, but I had similar problems on OS X (and gave up on it, actually). With ADO.NET everything works fine, but that won't solve your problem either. ;-) |
| ||
Hallo. There's a .a file included with the module (in lib/win32). This was created from the .lib file that comes with MySQL. Currently you will need to copy this file to BlitzMax/lib. However, since 1.28 of BlitzMax now supports some funky new functionality, you can also add : ModuleInfo "LD_OPTS: %PWD%/lib/win32" to the module to allow it to find the file in the proper place without having to copy it anywhere. I'll see about updating the module to support this by default - so as to save you the effort. On OS X it is even easier to get working... ;-) |
| ||
I copied the .a to corrsponding module folder and it built fine(same as irrlicht). That sould solve the build problem, since 1.28 the Brucey BMK has already in, there's not many thing to be modified. |
| ||
Ok, thanks Brucey. I copied the .a file to the BlitzMax/lib folder (later I noticed a hint in the ModuleInfo of dbmysql.bmx ;). Next problem: when building test_01.bmx I get the following error: Unable to locate component This application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem. The .dll file is located in C:\Program Files\MySQL\MySQL Server 5.0\bin What else do I need to do to make the demo running? |
| ||
The program needs to be able to find the DLL, either put it in your app directory, or put it in the Windows\System32 directory, or put it in a directory that is in your path. |
| ||
Looks like it's working. Thanks guys! |