note 119206 deleted from intro.mssql by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:42:09 +0000 |
| Subject: | note 119206 deleted from intro.mssql by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215275@lists.php.net to get a copy of this message | ||
Note Submitter: rjaehnrich at gmail dot com
----
to use MSSQL-connections on Linux with PHP7 you can use PDO with PDO_DBLIB.
Install driver using this command:
sudo apt-get install php7.0-sybase
then simply connect with this:
<?php
$dsn = "dblib:host=" . $host . ":1433;dbname=" . $database;
$dblink = new PDO ($dsn, $user, $pass);
?>
I got problems when i used the hostname, so i switched to the IP of the server.
Later I got problems to insert records into MSSQL-table.
This settings helped me out:
<?php
$dblink->exec("SET ANSI_WARNINGS ON");
$dblink->exec("SET ANSI_PADDING ON");
$dblink->exec("SET ANSI_NULLS ON");
$dblink->exec("SET QUOTED_IDENTIFIER ON");
$dblink->exec("SET CONCAT_NULL_YIELDS_NULL ON");
?>