4

It seems PHP PosgreSQL PDO driver does not accept charset parameter.

This does not work (as charset is missing in doc at http://www.php.net/manual/en/ref.pdo-pgsql.connection.php):

$db = new PDO('pgsql:host=localhost;dbname=database;charset=WIN1250', 'user', 'pass');

How can I set charset witch client is using?

4
  • 1
    SET NAMES? Are you sure this is PostgreSQL? Commented Jul 13, 2013 at 3:44
  • Yes I am. :-) At least everything works. See: postgresql.org/docs/8.3/static/multibyte.html#AEN27550 Commented Jul 13, 2013 at 7:39
  • 1
    Thankyou; I had no idea that PostgreSQL supported NAMES as an alias for client_encoding despite using the DB for years. Interesting. (It's a good idea to show select version() in your questions by the way). It isn't clear if your edit means that you actually found a solution to the problem or not. If you did, undelete your answer and explain it a little more. Commented Jul 13, 2013 at 10:11
  • Ok, I did revert my edits. Commented Jul 13, 2013 at 16:52

1 Answer 1

3

I found possibilities of how to set client charset in documentation and it seems followed query works fine:

SET NAMES 'WIN1250';
Sign up to request clarification or add additional context in comments.

2 Comments

Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question.
@TI users are entitled to answer their own questions. So, nothing wrong with this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.