# mysql_set_charset

- Thread: https://externals.io/message/39704
- Original archive: https://news-web.php.net/php.internals/39704
- Started by Stanislav Malyshev on 2008-08-06T16:31:46+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #39704 — Stanislav Malyshev — 2008-08-06T16:31:46+00:00

URL: https://externals.io/message/39704#39704

Hi!

I notice that mysql_set_charset function is not part of 5.3 tree and 
it's test is marked as "usage not recommended". Could you explain what 
is the reason for that? It's quite unusual to drop functions in later 
versions, and if mysql_set_charset() has some problem we should note 
that in the manual.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #39713 — Ulf Wendel — 2008-08-06T19:10:21+00:00

URL: https://externals.io/message/39704#39713 · In reply to: #39704

Stanislav Malyshev schrieb:
> I notice that mysql_set_charset function is not part of 5.3 tree and 
> it's test is marked as "usage not recommended". Could you explain what 
> is the reason for that? It's quite unusual to drop functions in later 
> versions, and if mysql_set_charset() has some problem we should note 
> that in the manual.

Hi Stas,

good find!

I think it has happened accidently in 5_3 at Revision 1.213.2.6.2.16.2.2 
when patching ext/mysql for mysqlnd some 10 months ago [1] . Its in 5_2 
and its in HEAD. Andrey is working on re-introducing it to ext/mysql in 
the 5_3 branch.

I don't recall why I added "usage not recommended" to the test. Let me 
check with Georg. He had some concerns on the function as far as I remember.

Ulf

[1] 
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?r1=1.213.2.6.2.16.2.1&r2=1.213.2.6.2.16.2.2

---

## #39714 — Ulf Wendel — 2008-08-06T20:22:36+00:00

URL: https://externals.io/message/39704#39714 · In reply to: #39713

Ulf Wendel schrieb:
> and its in HEAD. Andrey is working on re-introducing it to ext/mysql in 
> the 5_3 branch.

There it is http://news.php.net/php.cvs/52063

Ulf

---

## #39715 — Stanislav Malyshev — 2008-08-06T20:52:08+00:00

URL: https://externals.io/message/39704#39715 · In reply to: #39714

Hi!

> There it is http://news.php.net/php.cvs/52063

Thanks!
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #39734 — Ulf Wendel — 2008-08-07T14:17:31+00:00

URL: https://externals.io/message/39704#39734 · In reply to: #39713

Ulf Wendel schrieb:
> I don't recall why I added "usage not recommended" to the test. Let me 
> check with Georg. He had some concerns on the function as far as I 
> remember.

I checked with Georg. My memories regarding Georg's position are totally 
wrong. He once introduced mysql_set_charset to the MySQL Client Library 
(AKA "libmysql" - marketing gets confused when I use libmysql, sorry).

He explained to me that using SET NAMES is what is not recommended when 
using libmysql because:

  - there is no verification if the client knows the charset
  - the internal mysql->charset field will not be set properly

I don't know how that "usage not recommended" comment has crept in the 
test. Probably my fault...

Ulf

---

## #39735 — Hannes Magnusson — 2008-08-07T14:29:12+00:00

URL: https://externals.io/message/39704#39735 · In reply to: #39734

> He explained to me that using SET NAMES is what is not recommended when
> using libmysql because:
>
>  - there is no verification if the client knows the charset
>  - the internal mysql->charset field will not be set properly

Is this something we should add to the mysql[i]_set_charset() docs?
I've seen *bunch* of people doing mysql[i]_query("SET NAMES UTF8");...

-Hannes

---

## #39737 — Lukas Kahwe Smith — 2008-08-07T14:34:53+00:00

URL: https://externals.io/message/39704#39737 · In reply to: #39735

> 
> > […]
>
> Is this something we should add to the mysql[i]_set_charset() docs?
> I've seen *bunch* of people doing mysql[i]_query("SET NAMES UTF8");...


yes .. most people do it for historical reasons, or because they did  
not want to clutter their libraries with `function_exists()` calls.

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #39736 — Scott MacVicar — 2008-08-07T14:36:39+00:00

URL: https://externals.io/message/39704#39736 · In reply to: #39735

Hannes Magnusson wrote:
> 
> > […]
> 
> Is this something we should add to the mysql[i]_set_charset() docs?
> I've seen *bunch* of people doing mysql[i]_query("SET NAMES UTF8");...
> 
> -Hannes
> 

The people doing it usually have to support PHP versions lower than 
5.2.3, we use SET NAMES on older versions of PHP.

Scott

---

## #40094 — Alexey Zakhlestin — 2008-08-26T15:04:09+00:00

URL: https://externals.io/message/39704#40094 · In reply to: #39735

On Thu, Aug 7, 2008 at 6:29 PM, Hannes Magnusson
<hannes.magnusson@gmail.com> wrote:
> 
> > […]
>
> Is this something we should add to the mysql[i]_set_charset() docs?
> I've seen *bunch* of people doing mysql[i]_query("SET NAMES UTF8");...

Is it possible to add similiar functionality to pdo_mysql?
Probably in the form of custom option.

-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/
