J
J
JP_Cool2017-06-17 17:36:40
PHP
JP_Cool, 2017-06-17 17:36:40

Is it possible to use one database when writing a site in PHP, and an android application in Java?

I want to write a website, for this I know PHP and the Yii2 framework, I want to make an android application for it, I know Java for this. The site and application must use 1 database. Should I also learn Java EE to write a website on it, or how can I implement this with 2 programming languages? If so, roughly how?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
huwesu, 2017-06-17
@huwesu

Use base where?
On Android locally and on the site? That is, in fact, these will be 2 identical bases?
Or one common database on the Internet, available to all Androids?
If about the second option, then it’s more correct to do it indirectly, as finjoiler wrote in his example.
And through the implementation of the API on the site.
That is, only PHP will have access to the database, and the Android application will already access PHP via the API.

V
Vladislav, 2017-06-17
@Div100

Yes, you can.
Imagine that the bd is a basket with things or a closet. You can take and put from there. Besides you, I can do it or another person who has the key to it.
That is, in order for you to do this, you make your own website, it communicates with this database.
In order for the application to communicate with this base, you need to make an API that will stand between the base and the application.
Of course, you can directly access the database from the application, as well as from the site.
But this is not safe, because your site is running on the server and all configs with passwords will not be able to see the user, and in the case of a mobile phone, you will have access registered in the application itself. This means that anyone can take it apart and look at it.
Look towards REST API.
For example, to save some kind of record to the database, you will need to send a request to your server, which will accept it, process the data and do what is needed. For example, you have such a route (route / endpoint):
POST your-site.com/item/save
You already define on the server how it will work.

M
Mr Hobot, 2017-06-17
@vashaaa

Write rest api on the back of the site. Use the application to send API requests, and you will be happy.

A
Andrey Prozorov, 2017-06-20
@i_d_1

php api giving json on request from the application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question