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 ?

Femn Dharamshi
  • 527
  • 1
  • 9
  • 25
  • That makes sense to me. – Harvey Fletcher Nov 23 '18 at 08: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 – Vladyslav Matviienko Nov 23 '18 at 08: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) – Femn Dharamshi Nov 23 '18 at 16:51

1 Answers1

1

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

How to write a REST API?

Ajit Maurya
  • 56
  • 1
  • 9