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

Bug: CodeIgniter v4.5.1 When I connect Postgres Database I Received Error #8912

Closed
NavinRiyaz opened this issue May 24, 2024 · 4 comments
Closed
Labels
duplicate Issue or pull request duplicates an already existing issue/pull request

Comments

@NavinRiyaz
Copy link

PHP Version

8.2

CodeIgniter4 Version

4.1.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

PostgreSQL 16

What happened?

When connect PostgreSQL server via .env. I received error like attached file. Even my Connections are successfully connected. Here is my ENV file.


#--------------------------------------------------------------------
# Example Environment Configuration file
#
# This file can be used as a starting point for your own
# custom .env files, and contains most of the possible settings
# available in a default install.
#
# By default, all of the settings are commented out. If you want
# to override the setting, you must un-comment it by removing the '#'
# at the beginning of the line.
#--------------------------------------------------------------------

#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------

CI_ENVIRONMENT = development

#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------

app.baseURL = 'http://localhost/myapp/public/'
# If you have trouble with `.`, you could also use `_`.
# app_baseURL = ''
# app.forceGlobalSecureRequests = false
# app.CSPEnabled = false

#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------

database.default.hostname = 127.0.0.1
database.default.database = myapp
database.default.username = postgres
database.default.password = postgres
database.default.DBDriver = Postgre
database.default.DBPrefix =
database.default.port = 5432

# If you use MySQLi as tests, first update the values of Config\Database::$tests.
# database.tests.hostname = localhost
# database.tests.database = ci4_test
# database.tests.username = root
# database.tests.password = root
# database.tests.DBDriver = MySQLi
# database.tests.DBPrefix =
# database.tests.charset = utf8mb4
# database.tests.DBCollat = utf8mb4_general_ci
# database.tests.port = 3306

#--------------------------------------------------------------------
# ENCRYPTION
#--------------------------------------------------------------------

# encryption.key =

#--------------------------------------------------------------------
# SESSION
#--------------------------------------------------------------------

# session.driver = 'CodeIgniter\Session\Handlers\FileHandler'
# session.savePath = null

#--------------------------------------------------------------------
# LOGGER
#--------------------------------------------------------------------

# logger.threshold = 4

DB Error

Steps to Reproduce

  1. Change ENV Database variable to Postgres
  2. Make Migrations
  3. Run php spark migrate

Expected Output

Database connected without errors

Anything else?

N/A

@NavinRiyaz NavinRiyaz added the bug Verified issues on the current code behavior or pull requests that will fix them label May 24, 2024
@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label May 24, 2024
@kenjis
Copy link
Member

kenjis commented May 24, 2024

I don't know why you get the error.
But see #8903 (comment)

@kenjis kenjis changed the title Bug: CodeIgniter v4.5.1 Version When I connect Postgres Database. I Received Error Bug: CodeIgniter v4.5.1 When I connect Postgres Database I Received Error May 24, 2024
@NavinRiyaz
Copy link
Author

Thank you @kenjis It's Working

@kenjis kenjis added the duplicate Issue or pull request duplicates an already existing issue/pull request label May 24, 2024
@kenjis
Copy link
Member

kenjis commented May 25, 2024

This error is because of the change to charset in the Database config file.
The $default is for MySQL:

'charset' => 'utf8mb4',

But utf8mb4 is invalid to PostgreSQL.

@rjwmtgevolution
Copy link

beautiful, thank you for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issue or pull request duplicates an already existing issue/pull request
Projects
None yet
Development

No branches or pull requests

3 participants