SQL Server with custom port |
Using SQL Server with default port (1433) is work well. But when we use custom port, the .env or config field database.nls.port = 5000, its not given any effect, didn't work.
So, I tried to change connection syntax inside Connection.php core class CodeIgniter\Database\SQLSRV\Connection. My questions: 1. Is this a bug ? because field database.nls.port (.env) or $default['port'] (config) doesn't work if we use custom port (especially for SQLSRV) 2. How do we override this Connection class. (Yes, I already read in the doc, create our own class, and register in autoload, but it didn't work). Thank you.
I found this documentation at Microsoft:
https://docs.microsoft.com/en-us/sql/con...rver-ver16 It looks like you need to add the port to the hostname. $serverName = "myServer, 1521"; sqlsrv_connect( $serverName ); in system/Database/SQLSRV/Connection.php at Line 123 PHP Code: sqlsrv_configure('WarningsReturnAsErrors', 0); to test it change it to: PHP Code: sqlsrv_configure('WarningsReturnAsErrors', 0); if that works, it's a bug. I can't test it right now because I don't have access to an sql server (05-23-2022, 08:19 PM)ilyani Wrote: Using SQL Server with default port (1433) is work well. But when we use custom port, the .env or config field database.nls.port = 5000, its not given any effect, didn't work. Here file I modified, connect() method Connection.php for SQLSRV under /vendor/codeigniter4/framework/system/Database/SQLSRV/Connection.php from this PHP Code: ... to this PHP Code: ... How to override this Connection class, without direct modify like this? Thanks
1. This is a bug.
2. If I'm not mistaken, you can't replace just the connection class. You need to fully implement the driver.
See
a simple way to extend the Database classes https://forum.codeigniter.com/thread-782...#pid383813
Can you help try to specify the port in hostname 'hostname' => 'host, port',
I don't know if this will work.
This bug was fixed in the `develop` branch.
https://github.com/codeigniter4/CodeIgniter4/pull/6036 And it would be included in v4.2.0. |
Welcome Guest, Not a member yet? Register Sign In |