Skip to content

Instantly share code, notes, and snippets.

@LinZap
Created January 13, 2016 00:43
Show Gist options
  • Save LinZap/897d2a42ca0575c428cf to your computer and use it in GitHub Desktop.
Save LinZap/897d2a42ca0575c428cf to your computer and use it in GitHub Desktop.
CH_JSON TEST
<?php
try {
$db = new PDO("sqlsrv:server=localhost;Database=rec-booklife","zap","123");
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch( PDOException $e ) {
die( "Error connecting to SQL Server:".$e );
}
$stmt = $db->prepare("select top 100 oid,cname from book");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_CLASS);
echo json_encode($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment