Hi all,
I'm thinking about using the CloudKVS in a project but I want to use a hosted service I have, for the database. I can't have my own server for different reasons.
This hosted-server will not allow me to run java-code so I'm thinking about using a php-file that handles the connection between the app and the DB.
In a previous app I've used the code below to connect with the DB.
In the app:
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
Log("main.erm: Query sent " & Query)
job.PostString("http://www.xxxxx.se/db.php", Query)
End Sub
And the file db.php:
<?
$databasehost = "xxxxl";
$databasename = "xxxxx";
$databaseusername ="xxxx";
$databasepassword = "xxxxxx";
$con = mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error());
mysql_select_db($databasename) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
$query = file_get_contents("php://input");
$sth = mysql_query($query);
if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
Would this work for ClodKVS too?
If so, do I need to change anything in the code for B4A example?
The ServerUrl of course but apart from that? The rest looks like standard DB commands.
I need to get the password for the DB from a better place though. Anyone has any ideas about that?