<?php
$serverName = "servername";
$connectionInfo = array("Database"=>"DB", "UID"=>"user1", "PWD"=>"[email protected]");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn) {
echo "Connection established.<br />";
}
else{
echo "Connection could not be established.<br />";
die(print_r(sqlsrv_errors(), true));
}
$sql = "SELECT
COUNT(CASE WHEN online = 'Yes' THEN city END) AS o_total,
COUNT(CASE WHEN online = 'No' THEN city END) AS o_offline,
COUNT(*) as t_total,
COUNT(CASE WHEN online = 'Yes' AND channel='Name1' THEN city END) AS o_Name1,
COUNT(CASE WHEN channel='Name1' THEN city END) AS t_Name1,
COUNT(CASE WHEN online = 'YES' AND channel='Name2' THEN city END) AS o_Name2,
COUNT(CASE WHEN channel='Name2' THEN city END) AS t_Name2,
COUNT(CASE WHEN online = 'Yes' AND channel='Name3' THEN city END) AS o_Name3,
COUNT(CASE WHEN channel='Name3' THEN city END) AS t_Name3,
COUNT(CASE WHEN online = 'Yes' AND channel='Name4' THEN city END) AS o_Name4,
COUNT(CASE WHEN channel='Name4' THEN city END) AS t_Name4,
city FROM wmm group by city";
$result = $conn->query($sql);
$array = new stdClass();
if ($result->num_rows > 0) {
while($row = sqlsrv_fetch_assoc($result)) {
$array->$row['city'] = $row;
}
echo json_encode($array);
}
?>
私は、エラー=>致命的なエラーが発生しまし持っています:Cで非オブジェクトのメンバ関数のクエリ()の呼び出し:\ xamppの\ htdocsに\ユーザー\ File.phpは
コール
ラインに接続をこのようにしてみてください事前
hereを文書化しているあなたは、 '$のconn'とあなたの「接続確立」の条件付きブロックで簡単なテストクエリ右の両方を渡す' sqlsrv_query'機能を、使用している場合は? http://fp.net/manual/en/function.sqlsrv-query.php –