//    if(empty($otherColumns)){
//    	echo("Please select the columns!");
//    }else{
//        for($i=0; $i < count($otherColumns); $i++){
//			$valueColumns .= "`" . $otherColumns[$i] . "` as 'valueColumn" . $i . "'";
//			if(!empty($otherColumns[$i+1])){
//				$valueColumns .= ", ";
//			}
//      }
//}
//	$sql = "SELECT `" . $firstColumn . "` as 'firstColumn', `" . $dateColumn . "` as 'dateColumn', ";
//	$sql .= $valueColumns;
//	$sql .= " FROM resultDoJoin ";
//	if (!empty($where))
//      $sql .= $where;
$rst = ExternalMSSQL::runQueryWithLinkedServers($query);
//	$rst = $db->get_results($sql);
$rows = array();
foreach ($rst as $r) {
    $rows[] = $r;
}
echo json_encode($rows);
/*
$titleNo = 0;
$firstColumn = "Location";
$dateColumn = "Spd";
$otherColumns = ['Households','Married Couples'];
*/
/*
$cols = "";
for($i=0; $i<count($otherColumns); $i++) {
 public static function GetTableDataBySidAndNameFromFile($sid, $table_name, $perPage, $pageNo)
 {
     $query = ExternalMSSQL::wrapInLimit($pageNo, $perPage, "(" . ExternalMSSQL::makeQueryToRotateTable($sid, $table_name, "*") . ") as b");
     return ExternalMSSQL::runQueryWithLinkedServers($query);
 }