Share database between app and web - php

I'm involved into an app that have to retrieve queries from an existing database. This db have to be implemented in php in a remote server, and will be the place where the admin will have to insert content into the shared db, but I don't know how to implement that correctly or what is the best solution.
I'm thinking about make a sqlite database with php and connect directly the app to the db, but I haven't found yet the best way to do that.
What do you think? Thank guys.

FYI, without any server communication (Web services) you can't use the website database in android application.
If you want to manage the communication between the website and the android app means you need a centralized server (probably my sql dab) which having the data of your web/mobile applications. So, after that by using the web service methods (REST/SOAP) you can achieve the communication between them
I'm thinking about make a sqlite database with php and connect
directly the app to the db, but I haven't found yet the best way to do
that.
This is not the right approach to connect mobile applications with the database. Instead you should create a middleware(REST/SOAP webservice) which runs on server. This middleware will in turn connect with the database and your mobile app whether it is android, iOS or windows app can communicate with this middleware.

Related

How can I connect to my MySQL database backend through Android without exposing it to the public?

I've made an app for Android that uses the Retrofit HTTP API to call PHP scripts which query a database.
App -> Retrofit Call -> PHP -> Database
The PHP and the database are both hosted on the same Amazon EC2 instance.
I would like my app to be deployable to many users, but I don't know how to keep my backend private.
In order for the app to interact with the database, it must use the PHP and since users' IP addresses will vary, I have to keep that PHP code's host's IP address public so that all users can submit/download data.
The problem is that this leaves my backend open to anyone who wants to sniff out the IP address. How can I get around this issue? Is PHP/MySQL a bad choice for Android, or have I simply chosen the wrong platforms?
The best solution will be if you create an API backend for your app that in turn talks to your app-server and database. This is the standard practice of creating mobile applications that have cloud backends
AWS API Gateway would be a perfect fit for it. This is very cheap, responsive and a secure service.
Is encryption out of the question? You can encrypt/decrypt strings or data between android and PHP.
Some codes that I used can be found here: https://stackoverflow.com/a/20929131/7199177
You might have created APIs using PHP
You can develop the following mechanism using the PHP to secure your APIs:
list out the API which should be public like login, signup so anyone can access it.
All other APP should be accessible after a some authentication only.
Your APIs should be talking to your Database server which is in a private subnet.
Other options:
Use API-Gateway with Lambda and your Database server:
To reduce the use of API-gateway you can directly write a code in lambda and use aws-sdk in your application to call lambda. In backend use your database server.

frameworks for separate web app and database server

I'm having a hard time on choosing which platform will I be using in creating a separate web app and database. What could be the possible and more easier to use in creating a separate web app and database? I'm thinking of using PHP for the web app and the database server will be python. Is it gonna be convenient? Or should I use only the php for web app and connect it to the separated database server?

Connecting MySql with Android without using PHP

I want to connect a MySql DB with my android application.
However, I DON'T want to/CAN'T use PHP for doing this.
Almost all solution for MySql connection with android on internet uses PHP.
I read somewhere that, If one don't want to use PHP then web service should be used.
But I'm not able to find any tutorial/sample example for the same.
Any help appreciated.
It seems you're mixing up some things.
A web service is simply some code on the internet (web) which allows you to receive and send information to a server, where it is saved per example in a database.
PHP is just a language, in which you can write a web service.
You can use a vast array of languages to create a web service ( read: expose your database) to other devices. Among others, you can easily do this in Java, .NET, Python ...
If you're looking for a way to connect to an external database without any web service / API in between, i'll have to disappoint you with the news that this is not supported by Android.
Most examples of a simple web service / a bunch of scripts contain PHP since this is probably the easiest and can be used on pretty much any server.
A webservice, is as it's called, a service, meaning that you have one side consuming it (the android client). if all you want is a persistent storage, you could use SQLite which is an SQL compliant solution which exists within android.
If it's possible to SSH to a server via Android, you could use that to connect to mysql, because the only other solution involves having mysql binaries installed locally on your android machine, and that's not possible AS FAR AS I KNOW, on Android.
One major reason for using a webservice (e.g. written in PHP) to connect to a remote DB is that you don't want to store the database login credentials inside your app. Because otherwise it'll be easy to extract your login for that database and access and edit it in a way you might not have planned (eg. delete stuff).
Its Possible to connect mysql database .
I have done with out using php file . I have used an spring configuration file to establish an connection to the database and dao to access the data from the database.
Create an Web Application that access the Server through the Spring Framework and an Servlet .
Create an Android Client Application tat make an get / post request to the Servlet , process the results in the servlet and return the response to the Android Client Application (json format ) Process the json format reponse in the Android Client Side and use it to your application

How to develop a desktop application or exe file for the web app developed in PHP,so that the customer can access it when there is no internet

We have a web-application(Loyalty platform for restaurants) developed in PHP. But most of these merchants dont have internet connection all the time. So, is there way to convert only merchant module into a desktop application so that merchant works stand alone and it syncs to web application whenever there is an internet connection.
Yes it is possible ,but not like a wizard job.
If you know only PHP than you can use Titanium ,and deploy Desktop App's.
You can use a local database ,an XML ,jSON or SQLite and on the first connection with internet you can clear the local database and update the Remote one.
I am working on a similar project and in my case I am following the below aproach.
Web Application is PHP and MySQL
Desktop Application is .net Application using SQL Lite
Windows Service checks for internet connection and syncs db in the background
In my case, my users can go offline for days or weeks and data was critical for me and I felt HTML 5 offline content was not the best option for this.
No. Designing a desktop PHP app is very different from designing a web PHP app and will require major amounts of rearchitecting.
Now having said that, it is possible to deploy a web server to the client's machine and have it run a web PHP app there. It will still require some rearchitecting to get the sync working though.
Develop a desktop application in .net or Java what ever you are familiar with and use some database like SQLite to save the data locally. When ever the user goes to online you need to connect to your online database and sync the data.
If there is possibility that same data can be updated by different users, then you have to plan on handling the conflicting scenarios like if a data record is updated at both end which data should be used. If there is no possibility to concurrent update then simply you will have to upload your data when user goes online.

How do I connect to an external database such as MySQL in PALM webOS

I have a php code which i hosted on wampserver and a MySql database which I hosted in phpmyadmin. I have tried using Ajax request function which I wrote in the scene assistance file to call the PHP to access the database but its not working.
I would advise against connecting straight to the database from the device. Apps generally don't do that and there are very good reasons:
A database server such as mysql isn't very good with handling multiple low-latency connections.
You'll actually be allowing anybody access to the database and if you're using mysql's authentication for different users, that's not the best method. Will you be using SSL? because else the usersnames/passwords will be travelling through network pipes unfiltered exposing your server to multiple security risks.
Updates are harder, caching is impossible.. etc.. many reasons.
What most apps do is actually create a server side application that will handle requests from the app in a RESTful way. So your app will query something like http://myappdomain.com/objects/list and return json or XML etc..

Categories