If I understand correctly, you have a PHP Linux client to access SQL Server.
So you need to install Freetds on Linux [http://www.freetds.org/] .
My Freetds configuration file is on /usr/local/etc/freetds/freetds.conf
:
[mosaico]
host = servidor.meu.dominio
; ou host = 192.168.1.2 se preferir usar o IP do servidor ao invés do nome
port = 1433
tds version = 7.4
client charset = UTF-8
The entry named as mosaico
should be used for the bank call by PDO. Since PDO knows that the driver is Sqlserver, Freetds will provide additional information. But user and password do not stay in Freetds config file .
I am not accessing with PDO. I am using: [https://www.php.net/manual/en/book.mssql.php]
My config file in the PHP application where I refer to the Freetds configuration:
[ms_sql_server]
host=mosaico
user=MosaicoLeitura
password=MosaicoLeitura
And here as I call the MS SQL Server database:
final class MsSqlSrvDAOFactory extends DAOFactory
{
private static $host = null;
private static $user = null;
private static $pass = null;
function __construct()
{
$config = Config::get()["ms_sql_server"];
self::$host = $config["host"]; //vai retornar mosaico
self::$user = $config["user"]; //vai retornar MosaicoLeitura
self::$pass = $config["password"];// também retorna MosaicoLeitura
}
/**
*
* {@inheritDoc}
*
* @see \DarthEv\Core\interop\dao\DAOFactory::getUteDAO()
*/
public function getUteDAO() {
try {
return new MsSqlSrvUteDAO(self::$host, self::$user, self::$pass);
} catch (Exception $e) {
throw $e;
}
}
}
The following prompts the driver (I omitted the rest of the class to show how to instantiate):
$conn = null;
$conn = odbc_connect(self::$host, self::$user, self::$pass);
//a consulta vai a seguir:
$rs = odbc_exec($sql, $conn);
Above: $host is the name "mosaic" as in the previous class, which reads the application configuration data.
I hope I’ve helped.
But you set (fixed) the door too? Because each instance named runs over its own door (I think), just the way you did I think it will try the standard door, which is probably not available, because the instance is using another.
– Guilherme Nascimento