Welcome Guest, Not a member yet? Register   Sign In
MSSQL connection fails with hostname and requires more parameters
#1

Hi there,
I'm new using Codeigniter4, i try to read all the documentation about and see some Tutorials. The problem i found is the follow:
For some reasons the client i have use PHP in a Windows Server with MSSQL (we have other projects without any framework with the same configurations working fine). The problem we found was when we try to set the conection with CI4 show us an error that couldn't connect to the host, so we debug some files in the framework code to see what was the problem. What we found was, even when we configure parameter "port" to '' or nothing or even ' ' the system convert it to int and in file /vendor/codeigniter4/framework/system/Database/SQLSRV/Connection.php we need to comment this lines (124 to 126):
//if (strpos($this->hostname, ',') === false && $this->port !== '') {
//    $this->hostname .= ', ' . $this->port;
//}

Before anything i double check in my .env file that parameter database.default.port was set to '' or ' ' or even nothing.
Doing that and also adding one more parameter to array $connection then the conection was stablish fine. The missing parameter is 'TrustServerCertificate' (that could take true or false values).
Regards
Reply
#2

Please create an issue on the CodeIgniter GitHub site.

CodeIgniter Development GitHub
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

[SQLSRV] connection class does not allow for passing `TrustServerCertificate` setting in database configurations. · Issue #7095 · codeigniter4/CodeIgniter4
https://github.com/codeigniter4/CodeIgni...ssues/7095
Reply




Theme © iAndrew 2016 - Forum software by © MyBB