Advertisement
Guest User

Untitled

a guest
Jul 21st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. {"name":"Bocado","street":"887 Howell Mill Rd","city":"Atlanta",
  2. "state":"GA","zipcode":"30318","firstname":"Prit","lastname":"Patel","email":"ppatel@gmail.com",
  3. "totalscore":"40","count":"2"}
  4.  
  5. {"name":"Bocado","street":"887 Howell Mill Rd","city":"Atlanta",
  6. "state":"GA","zipcode":"30318","firstname":"Prit","lastname":"Patel","email":"ppatel@gmail.com",
  7. "totalscore":"40","count":"2", "Complaint1": "Service was bad", "Complaint 2": "I saw a rat on the floor".}
  8.  
  9. public function getWorstRestaurant($year, $complaints, $inspectionScore) {
  10. $json = array();
  11. $connection = $this->db->getDb();
  12.  
  13. $Result = mysqli_query($connection, "select name,
  14. street, city, state, zipcode, firstname, lastname, o.email,
  15. max(totalscore) as totalscore, count(*) as count from restaurant
  16. r join operatorowner o on o.email = r.email join complaint c
  17. on c.rid = r.rid join (select i.* from inspection i where year(i.idate) = '$year'
  18. and i.totalscore <= '$inspectionScore' and i.passfail = 'FAIL' order by idate desc limit 1) i on i.rid = r.rid group by name, street, city, state, zipcode, firstname, lastname, email having count(*) >= '$complaints'");
  19.  
  20.  
  21. while ($r = mysqli_fetch_assoc($Result)) {
  22. $json[] = $r;
  23. }
  24. return $json;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement