- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
I want to connect my app to a mysql database to query and display information.
Is that something that is possible with Intel XDK?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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
コピーされたリンク
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
I personally use webservices to retrieve JSON datas from website.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
I am going to give Dream Factory a try, If not I will try the other options
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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);
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Dreamfactory can connect to remote databases, you may install it anywhere.
Regards
Diego