@nalan90
2022-06-28T08:17:15.000000Z
字数 1685
阅读 543
Linux
yum install epel-release yum-utilsyum install http://rpms.remirepo.net/enterprise/remi-release-7.rpmyum install -y php73 php73-php-devel php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-pecl-swoole php73-php-recode php73-php-snmp php73-php-soap php73-php-xml php73-php-redis
wget http://pear.php.net/go-pear.phar -O go-pear.php/opt/remi/php73/root/usr/bin/php go-pear.php
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssqlrelease.repoyum -y install msodbcsql mssql-tools unixODBC-devel
sudo pecl install sqlsrvsudo pecl install pdo_sqlsrv编辑/etc/opt/remi/php73/php.d/20-pdo.iniextension=pdoextension=sqlsrv.soextension=pdo_sqlsrv.so
https://www.microsoft.com/en-us/sql-server/developer-get-started/php/rhel<?php$serverName = "121.33.75.18,3019";$connectionOptions = ["Database" => "middleDB","Uid" => "kes","PWD" => "Kblkes2020"];//Establishes the connection$conn = sqlsrv_connect($serverName, $connectionOptions);$tsql= "SELECT orderNum, shipmentNum FROM kes_order_master;";$getResults= sqlsrv_query($conn, $tsql);echo ("Reading data from table" . PHP_EOL);if ($getResults == FALSE)die(FormatErrors(sqlsrv_errors()));while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {echo ($row['orderNum'] . " " . $row['shipmentNum'] . PHP_EOL);}sqlsrv_free_stmt($getResults);function FormatErrors( $errors ){/* Display errors. */echo "Error information: ";foreach ( $errors as $error ){echo "SQLSTATE: ".$error['SQLSTATE']."";echo "Code: ".$error['code']."";echo "Message: ".$error['message']."";}}