使用自訂 repo 的方式無法順利安裝 php-gd 等待測試更新
--
參考
--
安裝 php-mssql
1 |
yum install php-mssql |
--
PHP 範例程式
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $link = mssql_connect('Server IP', 'Username', 'Password'); if (!$link) die('error'); else echo('ok'); $sql = " SELECT * FROM dbo.batch_id "; $query = mssql_query($sql); $row = mssql_fetch_array($query); print_r($row); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?php $dsn = 'dblib:host=Server IP;dbname=Database Name;'; $user = 'Username'; $password = 'Password'; // 建立 PDO 物件 $pdo = new PDO($dsn, $user, $password); $sql = " SELECT * FROM database.dbo.table "; $pre = $pdo->prepare($sql); $pre->execute(); $row = $pre->fetchAll(2); print_r($row); |
--
UTF-8 設定
參考
- Getting data with UTF-8 charset from MSSQL server using PHP FreeTDS extension
- FreeTDS - Return UTF-8 Character Set Data
vi /etc/freetds.conf
1 2 3 4 5 |
[global] # TDS protocol version tds version = 7.0 client charset = UTF-8 |
--
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@localhost:~] # tsql -C Compile-time settings (established with the "configure" script) Version: freetds v0.91 freetds.conf directory: /etc MS db-lib source compatibility: yes Sybase binary compatibility: yes Thread safety: yes iconv library: yes TDS version: 4.2 iODBC: no unixodbc: yes SSPI "trusted" logins: no Kerberos: yes |
--
MS SQL Server 語法
1 |
INSERT INTO table ( [column] ) VALUES ( 'column' ) |
這是一個很簡單的範例,SQL Server 的欄位名稱以 [] 方括弧包住,值也是使用 ' 單引號
--
1,142 total views, 4 views today