MySQL databases?

Monkey Forums/Monkey Beginners/MySQL databases?

Farflame(Posted 2015) [#1]
In my endless search for my perfect language, I've returned to Monkey because it ticks 2 of my 'required' boxes. 1) HTML5 and 2) BASIC (I still love Blitz Basic and hate every other language!!).

But I require database access in my project. I can't remember ever seeing if this was possible in Monkey and I've been playing around with PHP in the meantime (and not enjoying it, though I'm fairly fluent now). Is it possible, perhaps through PHP scripts?


GC-Martijn(Posted 2015) [#2]
can't you use a json request with MySQL?
or just sent the vars to a url ?
like ajax, because if your target is html5 you need to do something like that


Danilo(Posted 2015) [#3]
Maybe SQL.js could help?


Farflame(Posted 2015) [#4]
Yeah I'd be happy to send the vars to an url. That's doable in Monkey then? Sorry, been away for a while. And I can retrieve info in a similar way?

Thanks for the link, is this something I'd need to add to my project?


GC-Martijn(Posted 2015) [#5]
I dont have the timeto check, but maybe its easy to use two scripts.
1.) http://www.monkey-x.com/docs/html/Modules_brl.socket.html
For the client,that connects to a php socket.
2.) the php sockets receives and send the mysql data

I dunno if it working wirh ssl, but maybe not needed

Edit
I don't know if brl.socket is working for html5, maybe it is using ajax or websockets


ImmutableOctet(SKNG)(Posted 2015) [#6]
If you're planning on using HTTP I/O with a server, the 'brl.httprequest' module may help.


bitJericho(Posted 2015) [#7]
Farflame, the html5 target is client side, not serverside. You can't access a mysql database securely with monkey and client side code. What you can do is create a server side script that monkey can connect to. Monkey can easily connect to URLs with variables in the request (GET and POST). So make a server side API in php (or in monkey if you're ambitious).

http://coreymaynard.com/blog/creating-a-restful-api-with-php/


Farflame(Posted 2015) [#8]
Thanks for the answers. Plenty to be reading up on.

To clarify what I want to do. My project is an existing game (my livelihood) which is currently email based (therefore obviously turn-based). I want to upgrade it to an online, but still turn-based game. Basically exactly the same, just online. So for this I'll need a database stored on a host (already have that and I'm fairly fluent in MySQL) and I really want my players to access their turns via browser, so presumably I'll need to use HTML5 (sad that Monkey 2 won't be offering that then).

I've done some of it in PHP, so I'm fairly comfortable with that, but I REALLY don't like PHP and I really DO like BASIC.

So my plan is, the player logs in via their browser, the info is sent to a PHP script on my host (via POST), the script queries the database etc and sends back the response. Everything would done like that, which I think is correct?

So I need a language which is BASIC (my preference), OO (my preference), deploys to browser and can connect to URLs. Sounds like Monkey fits the bill? (But Monkey2 won't?)

Oh and I also need controls, such as textboxes and listboxes. But these can be added to Monkey somehow?


Samah(Posted 2015) [#9]
@Farflame: sad that Monkey 2 won't be offering that then

Mark has stated that he's going to look at compiling to Javascript with Emscripten, so an HTML5 target is still on the table.


Farflame(Posted 2015) [#10]
I hope so, I understand his reasoning that HTML5 was the least powered platform, but isn't HTML5 still looking promising for the future? HTML5 and BASIC really appeal to me and suit my needs.