You need a random sample of text from the database via javascript from the mysql database, without resorting to raising the server, followed by php.

Are there any standard features?

  • What for? In short - what exactly do you implement? (this is necessary in order to give an intelligible answer) - Zowie
  • we want to implement a mobile app on PhoneGap on an android. is it something like a tester with questions and a choice of answer. here's how to fasten the base? - Maria Baihanova
  • IMHO - there are 2 options that do not contradict the kiss: a) server b) store all data directly in the code If the questions do not change (or rarely change) I would choose the second, if the questions are replenished - I wrote would be a server. Generally with tz. Security - direct connection from the database, to put it mildly, is not the best solution; moreover, there is probably no direct means for this. - Zowie
  • one
    Possible duplicate question: JavaScript + MySql? - newman

4 answers 4

made from comments.


There are 2 options that do not contradict the kiss :

  1. server
  2. all data stored directly in the code

If the questions will not change (or will rarely change), I would choose the second.

In the event that questions will be replenished - would write a server.

In general, from a security point of view, a direct connection to the database, to put it mildly, is not the best solution; moreover, there is simply no direct means for this.

    In any case, MySQL will spin on the server, so there is a server. If you really want to stay in the framework of JS - Node.JS to help, twist on the server, let it execute requests and give answers in the same Json. Will shustrenko.

    In this case, at least, it will not be necessary to store the login / password for the connection in all instances of the application.

    The second option is SQLite. Local file on your smartphone, then create what you want. Updating the database of questions - downloading a new file.

    • mysql can spin both locally and without a server, only there is no point in this, yes) - Artem Gorlachev
    • Well, the problem here is that the target application was planned to turn on the android 4 years ago, and it is somewhat strange to drag Mysql to the android - Alex Prisyazhny

    In modern browsers, there is a noSQL database embedded . But with mysql without raising the server at least locally, you will not be able to do it in any way (node.js is also raising the server).

      Without a server to make access to the database is not possible. JavaScript runs in the browser, the browser sends requests to the web server, the web server sends this request to an interpreter such as php (or any other server technology), and only after that in the server script you can contact the database. Then everything in the reverse order from the database returns the data to the script, from the script to the web server, from the web server to the browser. It is impossible to access the database via JS from the browser bypassing the server.