Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2. $user = 'username';
  3. $passowrd = 'password';
  4. $conn = new PDO('mysql:host=ip;dbname=DBName;port=3306',$user,$passowrd);
  5. ?>
  6.  
  7. <?php
  8. include 'DB.php';
  9.  
  10. class Manager {
  11.  
  12. function jsonQuery() {
  13.  
  14. $response = array ();
  15.  
  16.  
  17. $st = $conn->query ( "query");
  18.  
  19. $response ["results"] = array ();
  20.  
  21. foreach ( $st->fetchAll () as $row ) {
  22.  
  23. //my stuff with the query
  24. }
  25.  
  26. $response ["success"] = 1;
  27.  
  28. echo json_encode ( $response );
  29. }
  30.  
  31. }
  32.  
  33. $object = new Manager();
  34.  
  35. $object->jsonQuery();
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement