Created
January 13, 2016 00:43
-
-
Save LinZap/897d2a42ca0575c428cf to your computer and use it in GitHub Desktop.
CH_JSON TEST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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