Skip to content

Instantly share code, notes, and snippets.

@zettca
Last active December 2, 2015 16:25
Show Gist options
  • Save zettca/7573b1d2a996043c3b60 to your computer and use it in GitHub Desktop.
Save zettca/7573b1d2a996043c3b60 to your computer and use it in GitHub Desktop.
Para quem não quiser escrever código PHP
<?php
header('Content-Type: application/json');
try{
$host="db.ist.utl.pt";
$port=3306;
$socket="";
$user="ist178013";
$password="gzhs9356";
$dbname="ist178013";
$con = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $user, $password);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $_REQUEST['query'];
$stmt = $con->prepare($query);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results);
$con = null;
} catch (Exception $e){
echo $e->getMessage();
}
?>
@zettca
Copy link
Author

zettca commented Dec 2, 2015

Para quem não quiser escrever php, executam pela query string ?query=QUERY e o gajo retorna um documento .json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment