Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.  
  3. $dbconn = pg_connect("host=localhost port=5432 dbname=smsgate user=smsgate password=smsgate");
  4.  
  5. $key = pg_escape_string($_GET["key"]);
  6.  
  7. $query = "SELECT * FROM sms WHERE meta->>'key'='$key'";
  8.  
  9.  
  10. $result = pg_query($query) or die('Query failed: ' . pg_last_error());
  11.  
  12.  
  13. $response = array();
  14.  
  15. while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
  16.     $meta = json_decode($line["meta"]);
  17.     $response[] = $meta;
  18. }
  19.  
  20. echo json_encode($response);
  21.  
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement