Page 1 of 1

App with multi-user-database?

Posted: Mon Jul 13, 2015 7:51 pm
by DevBoyLars
Hello,
is it possible in LiveCode to build a client App that connects to a server-database, so that multiple users can read/write to that database in a good speed?

Re: App with multi-user-database?

Posted: Mon Jul 13, 2015 9:58 pm
by ghettocottage
Yes, I am working on 3 different ones. They all work fine. I am having the best luck using Livecode Server as an intermediary. Here is a long-ish thread where we were discussing this to some extent:

http://forums.livecode.com/viewtopic.ph ... 08#p124508

Re: App with multi-user-database?

Posted: Sun Jul 26, 2015 1:10 pm
by DevBoyLars
Ok, so there's no direct-way to use something like a MySQL for every client without server-side coded software? I'm looking "just" for a way to store data in a server-based database. The server itself doesn't need to do anything - just store the data and every client should use it at the same time :D

Re: App with multi-user-database?

Posted: Sun Jul 26, 2015 3:32 pm
by AxWald
Hi,
DevBoyLars wrote:Ok, so there's no direct-way to use something like a MySQL for every client without server-side coded software?
For sure you could do this. If you can reach your MySQL directly from the internez, go on. Just make sure that no 2 users ever try to modify the same record at the same time! ;-)
This can be done marking the record to be "in use" before editing, and un-marking it after, and hoping this all will really work in an environment where's latency and lag. (check for "semaphor", "mutex", "lock") *1)

And be sure to have nothing important in this database, because chances are good it gets hijacked within a short time ...
{Input in field User: "John Doe'); Drop table USER;--"}

Or, and that's what most ppl do, you have some kind of "middleware". A process running on the server that acts as an "agent" between your users and the database. (Often such is made in PhP, but LC server, or even a LC standalone should do the trick as well, with less hassle. The thread ghettocottage has linked should be full of information related.)

Now all traffic is bundled on this agent, and you have 2 big advantages:
  1. Since your agent gets all the queries, it will nicely fulfill one after the other, and you don't need to care about write conflicts any more.
  2. Since all queries go through your agent, you have a nice point where you can filter entries - for instance, reject anything that contains certain chars like ";" etc.
Have fun!

*1) And if you use MySQL, be sure your tables support transactions - MyISAM doesn't! Choose your table type wisely or suffer later!

Re: App with multi-user-database?

Posted: Sun Jul 26, 2015 5:22 pm
by ghettocottage
DevBoyLars wrote:Ok, so there's no direct-way to use something like a MySQL for every client without server-side coded software? I'm looking "just" for a way to store data in a server-based database. The server itself doesn't need to do anything - just store the data and every client should use it at the same time :D
Livecode can do that, but if your database is on a remote server (that you use the internet to reach) there are some security issues (as Axwald mentioned).

By having Livecode Server installed on the same MySQL server, you can send your data requests to a livecode server file, and get back your data. This adds an extra layer of security to the transaction.

Having multiple users also has some issues, but nothing that cannot be solved with some thought and planning.