codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.25k stars 1.88k forks source link

BUG: I'm in the version 4.1.9 That works properly, but when I update to 4.2.1 the SQL Server 2017 #6165

Closed DASE1312 closed 2 years ago

DASE1312 commented 2 years ago

PHP Version

7.4

CodeIgniter4 Version

4.2.1

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

sqlserver 2017

What happened?

When I update to v 4.2.1. An error pop-up "CodeIgniter\Database\Exceptions\DatabaseException #8 Unable to connect to the database. Main connection [sqlsrv]: Proveedor de TCP: Tiempo de espera de la operación de espera agotado." I understand that the error is due to internet connection, but the device where i'm working is connected directly to the ethernet of the company.

Steps to Reproduce

I want to a login like i used to connect in the version 4.1.9 (i make a backup) , but the error pop-up

Expected Output

Validate the user to if there are register to the database

Anything else?

No response

DASE1312 commented 2 years ago

The data that I add is fictitious, but with the real data I can connect normally in version 4.1.9

    public $local = [
        'DSN' => '',
        'hostname' => '122.11.12.13\SQLEXPRESS',
        'username' => '12',
        'password' => '12',
        'database' => '12',
        'DBDriver' => 'sqlsrv',
        'DBPrefix' => '',
        'pConnect' => false,
        'DBDebug' => (ENVIRONMENT !== 'production'),
        'charset' => 'utf8',
        'DBCollat' => 'utf8_general_ci',
        'swapPre' => '',
        'encrypt' => false,
        'compress' => false,
        'strictOn' => false,
        'failover' => [],
        'port' => 1433,
    ];
iRedds commented 2 years ago

Try commenting out the port in the connection settings and connect to the database. Write if the behavior will change.

DASE1312 commented 2 years ago

Indeed, my friend, it was resolved by commenting on the port to which this behaviour is due, could you explain it to me?

iRedds commented 2 years ago

In 4.2.0, a fix was added to a bug due to which a port was not used when creating a connection to the database. That is, the connection always went through the default port. And if the server listened to a non-standard port, then the connection did not occur.

I want to note that all CI tests related to working with the database, including MSSQL, pass. Therefore, the reason for this behavior is currently unclear.