jdorn / php-reports

A PHP framework for displaying reports from any data source, including SQL and MongoDB
http://jdorn.github.com/php-reports
GNU Lesser General Public License v3.0
477 stars 235 forks source link

ado report can not connect to micrsoft sql server 2005 or later #127

Open yankevin opened 10 years ago

yankevin commented 10 years ago

I've tried a lot of ways to connect my mssql server 2005 via ado method within config.php. just like this: 'uri'=>'mssql://test:test@mymssqlservername/test' But, it can not work correctly. My environment is:- 1) Xampp 1.8.3 2) PHP 5.4.25 3) Microsoft SQL server 2005 After searching some clues by google, I find that adodb(http://adodb.sourceforge.net/) can not work with PHP5.4 to support for connecting MSSQL Server 2005 or later. To connect MSSQL Server 2005, we should download “Microsoft Drivers 3.0 for PHP for SQL Server” from the micrsoft.com. then, copy php_pdo_sqlsrv_54_ts.dll and php_sqlsrv_54_ts.dll to the folder of extension of php and also enable them. The example code like this: <?php /* Specify the server and connection string attributes. */ $serverName = "(local)";

/* Get UID and PWD from application-specific files. */ $uid = file_get_contents("C:\AppData\uid.txt"); $pwd = file_get_contents("C:\AppData\pwd.txt"); $connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>"AdventureWorks");

/* Connect using SQL Server Authentication. */ $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { echo "Unable to connect.
"; die( print_r( sqlsrv_errors(), true)); }

/* Query SQL Server for the login of the user accessing the database. */ $tsql = "SELECT CONVERT(varchar(32), SUSER_SNAME())"; $stmt = sqlsrv_query( $conn, $tsql); if( $stmt === false ) { echo "Error in executing query.
"; die( print_r( sqlsrv_errors(), true)); }

/* Retrieve and display the results of the query. */ $row = sqlsrv_fetch_array($stmt); echo "User login: ".$row[0]."
";

/* Free statement and connection resources. */ sqlsrv_free_stmt( $stmt); sqlsrv_close( $conn); ?>

Do you plan to support this function in the next version of php report? I really hope so.

jdorn commented 10 years ago

If you can't get AdoDB to work, you can always make a specific MSSQL report type. You should be able to pretty easily make a copy of classes/report_types/MysqlReportType.php and change the mysql methods to their sql server equivalents. For example, mysql_query would become sqlsrv_query.

I don't have access to a windows machine, so I can't make the changes and test them, but I'd be happy to merge in a pull request if you get it working.