- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I want to connect my app to a mysql database to query and display information.
Is that something that is possible with Intel XDK?
- Etiquetas:
- HTML5
- Intel® XDK
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi Robert,
I'm using Dreamfactory to access MySQL from XDK (www.dreamfactory.com). It is an opensource tool that generates automatically the REST API that Elroy is suggesting to implement just connecting your database. It works very well, handles autentication and has a lot of features more.
Additional to MySQL, it works with several databases more, including some NoSQL, I think it worth take a look and dedicate some time to learn it and testing.
Once you get the basics feel free to PM me for some sample code to use it from XDK.
Regards,
Diego
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
If you have a a mysql database on a server, I recommend implementing REST API on the server to allow access to the database entries from the client. Intel XDK allows you to create the application. It doesn't contain a feature to implement this for you.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi Robert,
I'm using Dreamfactory to access MySQL from XDK (www.dreamfactory.com). It is an opensource tool that generates automatically the REST API that Elroy is suggesting to implement just connecting your database. It works very well, handles autentication and has a lot of features more.
Additional to MySQL, it works with several databases more, including some NoSQL, I think it worth take a look and dedicate some time to learn it and testing.
Once you get the basics feel free to PM me for some sample code to use it from XDK.
Regards,
Diego
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi Robert
I just create a web service on the mysql server. The web service can be php or asp.net and can return JSON data to your app.
Please search my other postings for example code.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I personally use webservices to retrieve JSON datas from website.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I am going to give Dream Factory a try, If not I will try the other options
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi Diego,
I am developing an app for taking photos and location and upload them in a database (propably in phpMyAdmin). I also started using dreamfactory. Can you provide me some help on connecting the database with the xdk?
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
You can just use pure PHP, doing everything inside an iframe, that you host on a free hosting service.
This is the code you can use to connect to SQL
<?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?>
If you want to execute a query, you must use a code like this one:
$sql="Select * from Table_name"; $conn->query($sql);
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi Kiriakos,
Here is some sample code, it is for DreamFactory 2 or above.
//this function to connect, with a user defined in DF function logindf(mail, pass){ $.ajax({ type:'POST', beforeSend: function (request) { request.setRequestHeader('Content-Type','application/json'); request.setRequestHeader('X-DreamFactory-Api-Key','YourAPIKEY'); }, //urldf is your DreamFactory URL url: urlDf+'api/v2/user/session', data: '{"email":"'+mail+'", "password":"'+pass+'"}', success: function (response) { //save session in a global variable to use in other DF calls sesion = response.session_id; }, error: function (response) { alert('Se ha producido un error de acceso, por favor intente nuevamente'); console.log(JSON.stringify(response)); } }); //this is an example to get some data from a table $.ajax({ type:'GET', beforeSend: function (request) { request.setRequestHeader('X-DreamFactory-Application-Name', service); //the service name you set in DF request.setRequestHeader('X-DreamFactory-Session-Token', sesion); //the session from the login function request.setRequestHeader('X-DreamFactory-Api-Key','YourAPIKEY'); }, url: urlDf+'api/v2/'+service+'/_table/yourtable',//table name dataType: "json", success: function (data) { var len = data.resource.length; for (var i = 0; i < len; i++) { //process the result } }, error: function (response) { alert('Se ha producido un error al consultar la base de datos, por favor intente nuevamente'); alert(JSON.stringify(response)); } });
Regards
Diego
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Dream factory should be installed in the same host of the database in order to have access to the database, am I right? if it is installed in local copmuter it will not get the appropriate database, right?
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Dreamfactory can connect to remote databases, you may install it anywhere.
Regards
Diego

- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla