Monday, March 31, 2014

How to config SQLSRV and XAMPP 1.8.3 [PHP: 5.5.15]

ลองแล้วใช้งานได้

1. I grabbed the PHP drivers from here: http://www.microsoft.com/download/en/de ... n&id=20098
    ในกรณีนี้ใช้ Microsoft Drivers 3.0
   new สำหรับ php 5.5    http://sqlsrvphp.codeplex.com/discussions/441706
   http://www.hmelihkara.com/files/php_sqlsrv_55.rar

2. I extracted that package into a folder on my desktop
3. I copied "php_pdo_sqlsrv_54_ts.dll" and "php_sqlsrv_54_ts.dll" to my "/xampp/php/ext" folder
    or I copied "php_pdo_sqlsrv_55_ts.dll" and "php_sqlsrv_55_ts.dll" to my "/xampp/php/ext" folder
4. Added the extension lines to my "php.ini" file
    

5. ลง

Microsoft® SQL Server® 2012 Express
เลือกตัวนี้ ENU\x86\SQLEXPR_x86_ENU.exe  กด next next next finish..........
และลง 
http://go.microsoft.com/fwlink/?LinkID=239647&clcid=0x409

6. Started Apache via the Control Panel and it started up without crashing

You might want to consult this page for additional requirements/instructions: http://www.php.net/manual/en/sqlsrv.setup.php

7. ถ้ายังทำไม่ได้ยังไง ลองศึกษาในนี้ครับ
    http://sqlsrvphp.codeplex.com/discussions/441706
    http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html
    http://robsphp.blogspot.co.uk/2012/06/unofficial-microsoft-sql-server-driver.html
    https://onedrive.live.com/redir?resid=669EE24817961774%21720
    เหมือนกับทาง MS พยายามที่จะ build driver สำหรับ php 5.5 - 5.6 ออกมาแต่ก็ยังไม่คลอดออกมาเป็นแบบ official ตามเคย

ลองเทสคำสั้ง
<?php
$serverName 
"serverName\sqlexpress"//serverName\instanceName
$connectionInfo = array( "Database"=>"dbName""UID"=>"userName""PWD"=>"password");
$conn sqlsrv_connect$serverName$connectionInfo);

if( 
$conn ) {
     echo 
"Connection established.<br />";
}else{
     echo 
"Connection could not be established.<br />";
     die( 
print_rsqlsrv_errors(), true));
}
?>

ใช้งานได้