I could install und use the sqlsrv and sqlsrv_pdo driver packages from Microsoft on Windows and Ubuntu24.04 but for MacOS always failed to load connect to the driver at runtime!!!! Not even any php screen error logging works as in the php-file enabled:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$serverName = "1nnnnn“; // Or your server name
$connectionOptions = array(
"Database" => "Ifffffff“, // Your database name
"Uid" => "ddddddd“,
"PWD" => „passwoooord“,
);
//echo "???"; // when this two commented lines are uncommented the site shows ???
//exit(); // when this two commented lines are uncommented the site shows ???
$conn = sqlsrv_connect($serverName, $connectionOptions);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
echo "Connection successful!";
?>
XAMPP/Apache works fine for any php but when calling sqlsrv_connect the browser shows ‘unable to open’ and error in php_error_log-file is:
dyld[8251]: Assertion failed: (this->magic == kMagic), function loadAddress, file Loader.cpp, line 163.
The driver files are in correct location:
@MacBook-Pro-von-Ha---en no-debug-non-zts-20210902 % ls
opcache.so pdo_dblib.so pdo_sqlsrv.so pgsql.so sqlsrv.so
In the php.ini file extensions are loaded:
extension=sqlsrv.so
extension=pdo_sqlsrv.so
Correct access given:
-rwxr-xr-x@ 1 root admin 26720 6 Apr 2023 pdo_dblib.so
-rwxr-xr-x@ 1 root admin 333216 11 Sep 15:42 pdo_sqlsrv.so
-rwxr-xr-x@ 1 root admin 117680 6 Apr 2023 pgsql.so
-rwxr-xr-x@ 1 root admin 336880 11 Sep 17:14 sqlsrv.so
ODBC installed
g@MacBook-Pro-von-Ha---en no-debug-non-zts-20210902 % odbcinst -j
unixODBC 2.3.12
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /Users/hjbeling/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8