Ho un server windows dove c'è un db Sql Server.
Io vorrei collegarmi a questo db con php su Ubuntu 22.04.
Ho cercato dappertutto, provato in tutti i modi ma non riesco.
Mi sapete dare qualche dritta? Devo installare ODBC (anche se ho già provato senza successo)?
Grazie, buona giornata!
Ho provato questa soluzione https://askubuntu.com/questions/1407533 ... 11#1409311 ma eseguendo questo codice:
Codice: Seleziona tutto
$conn = \sqlsrv_connect(
$server,
[
'Database' => $db,
'UID' => $user,
'PWD' => $pass,
'CharacterSet' => 'UTF-8',
'Encrypt' => 1,
'TrustServerCertificate' => 1
]
);
if ($conn === false) {
echo "Unable to connect.</br>";
die(print_r(\sqlsrv_errors(), true));
}Codice: Seleziona tutto
Unable to connect.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 ) ) Codice: Seleziona tutto
if ! [[ "16.04 18.04 20.04 22.04" == *"$(lsb_release -rs)"* ]];
then
echo "Ubuntu $(lsb_release -rs) is not currently supported.";
exit;
fi
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install -y unixodbc-dev