playMaker

Author Topic: Work with MySQL  (Read 171 times)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 138
    • View Profile
    • multiplayer adult fighting
Work with MySQL
« on: April 02, 2019, 07:31:26 PM »
What is the easiest way to deal with MySQL? Let's say I need a simple task like found and delete some files from web hosted database, what should I use? Is there a common solution?
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4116
    • View Profile
    • jinxtergames
Re: Work with MySQL
« Reply #1 on: April 02, 2019, 10:16:13 PM »
Hi.
If you have easy save you can use that :)

here is in info for setting it up :

https://docs.moodkie.com/easy-save-2/guides/saving-and-loading-from-web/

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 138
    • View Profile
    • multiplayer adult fighting
Re: Work with MySQL
« Reply #2 on: April 04, 2019, 10:20:08 AM »
Actually, i'm looking exactly for a way to direct read&write MySQL database because of EasySave limitations. With ES I can serialize data and read/write certain files to their database (it's great, love it). But I can't proceed directly with MySQL requests.

For example:
1) I have an EasySave MySQL database over 1.5 GB.
2) I need to find all files with certain mask and delete them.

Solution 1, native ES actions:
a) download the list of all database files to unity array
b) iterate the array searching for mask and delete them one by one.
Last time I run this solution for 2.5 hours!!!

Solution 2, direct request to MySQL:
a) direct mysql request: DELETE FROM table_name [WHERE Clause]
less then a second!

So, I'm looking for a way to run MySQL requests to support my ES based solution.
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14057
  • Official Playmaker Support
    • View Profile
Re: Work with MySQL
« Reply #3 on: April 04, 2019, 11:30:16 PM »
Hi,

normally, your MySql databse is hosted on a server that also provides PHP, use PHP to create a REST api to control your database. This is the most documented and easy way out to control a database from apps.

 you can use https://fatfreeframework.com/3.6/home framework to deal with all the boilerplate code to create REST API. The ecosystem browser is using this framework for its operations.


you could use an asset like https://assetstore.unity.com/packages/tools/network/mysql-database-pro-139070 ( never used it, so I don't know if it works well or not). but that asset is what I mentionned above, it requires you to have a php server, and they simply provide the php file for you, and expose a c# script api to work with it.

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14057
  • Official Playmaker Support
    • View Profile
Re: Work with MySQL
« Reply #4 on: April 04, 2019, 11:34:48 PM »

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 138
    • View Profile
    • multiplayer adult fighting
Re: Work with MySQL
« Reply #5 on: April 05, 2019, 10:19:47 AM »
Thanks, seems legit! And what is the regular way to communicate with PHP scripts from playmaker?
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14057
  • Official Playmaker Support
    • View Profile
Re: Work with MySQL
« Reply #6 on: April 07, 2019, 11:01:40 PM »
Hi,

 a regular www call will do really.
 a php rest api is simply a "website" that doesn't have any frontend, it only returns data in a string format that can be xml or json or anything else really, it can return an image a video ( streaming or not), etc etc.

for example, the PlayMaker ecosystem browser, is doing just that:

 a simple website url like this:

http://www.fabrejean.net/projects/playmaker_ecosystem/search/float?content_type_mask=&repository_mask=U3U4U5&EcosystemVersion=0.6.4&UnityVersion=5.6.6f2&PlayMakerVersion=1.9.0.p13

will return only text.

a concrete hello world would be this link:

http://www.fabrejean.net/projects/playmaker_ecosystem/

 which is done in php and f3 framework like this:

Code: [Select]
$f3->route('GET /',
   function()
   {
      echo 'This is PlayMaker Ecosystem REST API v1.0. to search for Custom Actions, Templates Samples and Packages, use the <a href="https://hutonggames.fogbugz.com/default.asp?W1181" >Unity Ecosystem browser</a>';
    }
);


 Bye,

 Jean