gabordemooij / redbean

ORM layer that creates models, config and database on the fly
https://www.redbeanphp.com
2.31k stars 280 forks source link

Setting Charset and Collation for legacy application #948

Closed marios88 closed 2 weeks ago

marios88 commented 2 months ago

I would like to set Charset & Collation to latin1 & latin1_swedish_ci ideally without extending the class, is it possible to do it or a PR is needed?

https://github.com/gabordemooij/redbean/blob/1bb7b5b93031d1a458a503ee91b595c8f7a8c83d/RedBeanPHP/Driver/RPDO.php#L221

gabordemooij commented 2 weeks ago

You can set the encoding for the connection with this method, but it will not change the charset and collation for the database tables. Only utf8 is supported by RedBeanPHP. In theory you could create a QueryWriter that allows other charsets but I recommend against it. The only safe solution is to convert the database to utf8mb4. All other charsets are a nightmare.