http://www.microsoft.com/en-us/download/details.aspx?id=20098
For use with PHP 5.2 you need SQLSRV20.EXE instead for more details see
http://www.php.net/manual/en/sqlsrv.installation.php
2. Read instruction to install or run download file point location to php extension folder.
3. Install it will get file dll and manual in your extension folder.
4. add extension call in your php.ini file (this ex. use for PHP 5.4 thread safe version)
extension=php_sqlsrv_54_ts.dll
5. Go for Test Code.
/* Specify the server and connection string attributes. */
$serverName = "(localhost)\SQLExpress";
/* 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"=>"your_db_name");
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
echo "Unable to connect.</br>";
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.</br>";
die( print_r( sqlsrv_errors(), true));
}
/* Retrieve and display the results of the query. */
$row = sqlsrv_fetch_array($stmt);
echo "User login: ".$row[0]."</br>";
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
ไม่มีความคิดเห็น:
แสดงความคิดเห็น