1

So, currently i am using firebase for storing my app data online, I would like to create my own database, so i was planning to get a 100gb bandwidth hosting plan with php and mysql (is that bandwidth enought) per download, my app downloads approximately 0.4MB of data (as per firebase).

So, to create the api, i just have to encode the mysql data into json and print it ? then my android app will read it and use it ? is this the best method ?

$sth = mysqli_query("SELECT ...");
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
    $rows[] = $r;
}
print json_encode($rows);

or is there any other, more efficient method to do this ?

3
  • That makes sense to me. Commented Nov 23, 2018 at 8:49
  • is this the best method there is no best method, but it should work. (is that bandwidth enought) depends on how many users you will have, and how much data they will request. In other words - nobody knows Commented Nov 23, 2018 at 8:57
  • my data is 210kb, lets consider 400kb, 2000-4000 users per month, each user downloads 10 times lets say, that sums up to 15 gb i guess (considering higher end everywhere i guess) Commented Nov 23, 2018 at 16:51

1 Answer 1

1

Yes but you should send response code like 200,403 as well. here is a similar question

How to write a REST API?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.