Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set WarningsReturnAsErrors = 0 before connection #4762

Merged
merged 2 commits into from
Jun 2, 2021

Conversation

obelisk-services
Copy link
Contributor

Description

We have moved sqlsrv_configure('WarningsReturnAsErrors', 0); prior to sqlsrv_connect($this->hostname, $connection) because if there is a warning or an information message establishing the connection, it will treat it as an error and Codeigniter will throw an exception. Driver's configuration should be set prior the connection.

Example:
Before change, exception shows up (image1): "Unable to connect to the database. Main connection [SQLSRV]: Driver's SQLSetConnectAttr failed", but it is thrown by information message (IM006), as we can see when executing sqlsrv_errors() (image2).
Image1:
before

Image2:
information message

After change: Connection is established without problems:
after

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

If there is a warning establishing the connection, it will treat it as an error and Codeigniter will throw an exception. It should be configured prior the first sql command.
@paulbalandan
Copy link
Member

Please remove the extra whitespace.

@obelisk-services
Copy link
Contributor Author

Done :)

@paulbalandan paulbalandan merged commit 8fbba76 into codeigniter4:develop Jun 2, 2021
@paulbalandan
Copy link
Member

Thank you, @obelisk-services

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants