codeigniter4 / CodeIgniter4

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

Bug: SQLSRV schema is always 'dbo' #9270

Closed mieszkou closed 5 days ago

mieszkou commented 1 week ago

PHP Version

7.4, 8.0, 8.1, 8.2, 8.3

CodeIgniter4 Version

4.5.5

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

SQL 2019

What happened?

In an SQLSRV database, the database.default.schema parameter from the .env file is not recognized. The schema is always set to dbo, which appears to be hardcoded in the system/Database/SQLSRV/Connection.php file:

public $schema = 'dbo';

Steps to Reproduce

Using an SQLSRV database with a schema other than dbo.

Expected Output

SELECT * FROM Table

Anything else?

No response

michalsn commented 6 days ago

Please, make sure to define the schema key in the DB group you're using in the app/Config/Database.php file. Only then the variable from the .env file will be taken into account.

https://github.com/codeigniter4/CodeIgniter4/blob/develop/app/Config/Database.php#L112