PHP no longer uses the mssql_connect or mssql_* anything commands, they have replaced it with sqlsrv_connect or sqlsrv_* sometimes changing many of them entirely.
I managed to make the changes and tested the reports and it looks like it went through okay.
This is the database_mssql.php file, updated to use sqlsrv instead of mssql.
Code: Select all
"",
"database" => "",
"user_id" => "",
"password" => "",
);
$parameters = explode(";",$connection_string);
foreach($parameters as $parameter)
{
if (strpos($parameter, "=") 1) $value = $parts[1];
if (isset($value))
{
switch (strtolower($name))
{
case "data source":
case "server":
$info["host"] = $value;
break;
case "database":
case "initial catalog":
$info["database"] = $value;
break;
case "uid":
case "user":
case "user id":
$info["user_id"] = $value;
break;
case "password":
case "pwd":
$info["password"] = $value;
break;
}
}
}
return $info;
}
function sti_mssql_get_column_type($type)
{
switch($type)
{
case 2:
case 4:
return "int";
case 93:
case 91:
return "dateTime";
case 3:
case 7:
return "decimal";
}
return "string";
}
function sti_mssql_test_connection($connection_string)
{
$info = sti_mssql_parse_connection_string($connection_string);
$link = sqlsrv_connect($info["host"], array("UID" => $info["user_id"], "PWD" => $info["password"], "Database" => $info["database"])) or die("ServerError:Could not connect to host '".$info["host"]."'");
sqlsrv_close($link);
return "Successfull";
}
function sti_mssql_get_columns($connection_string, $query)
{
$info = sti_mssql_parse_connection_string($connection_string);
$link = sqlsrv_connect($info["host"], array("UID" => $info["user_id"], "PWD" => $info["password"], "Database" => $info["database"])) or die("ServerError:Could not connect to host '".$info["host"]."'");
$query = sti_parse_query_parameters($query);
$result = sqlsrv_query($link,$query) or die("ServerError:Data not found" );
$xml_output = "\n\n \n";
foreach(sqlsrv_field_metadata($result) as $field_metadata)
{
$column_type = sti_mssql_get_column_type($field_metadata["Type"]);
$xml_output .= " \n";
}
$xml_output .= " \n";
sqlsrv_free_stmt($result);
sqlsrv_close($link);
return $xml_output;
}
function sti_mssql_get_data($connection_string, $data_source_name, $query)
{
$info = sti_mssql_parse_connection_string($connection_string);
$link = sqlsrv_connect($info["host"], array("UID" => $info["user_id"], "PWD" => $info["password"], "Database" => $info["database"],"ReturnDatesAsStrings" => true)) or die( print_r( sqlsrv_errors(), true));
$query = sti_parse_query_parameters($query);
$result = sqlsrv_query($link,$query) or die("ServerError:Data not found");
$xml_output = "\n\n";
$columns = Array();
foreach(sqlsrv_field_metadata($result) as $field_metadata)
{
array_push($columns, $field_metadata);
}
while ($row = sqlsrv_fetch_array($result))
{
$xml_output .= " \n";
foreach($columns as $column)
{
$value = $row[$column["Name"]];
$value = str_replace("&", "&", $value);
$value = str_replace("", ">", $value);
$xml_output .= " $value\n";
}
$xml_output .= " \n";
}
$xml_output .= "";
sqlsrv_free_stmt($result);
sqlsrv_close($link);
return $xml_output;
}
?>