|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56993 utf-8 table-names cause syntax-error
Submitted: 2006-04-28 12:53 UTC Modified: 2007-12-19 09:57 UTC
From: indeyets at gmail dot com Assigned:
Status: Closed Package: PDO_MYSQL (PECL)
PHP Version: 5.1.2 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
15 + 37 = ?
Subscribe to this entry?

 [2006-04-28 12:53 UTC] indeyets at gmail dot com
notice: the same thing works just fine in mysql console!

whenever I try to prepare some statement which uses utf-8 named tables (cyrillics in my case) I get mysql syntax-error

Reproduce code:
$pdo->exec("SET NAMES utf8");

try {
    $sth = $pdo->prepare("SELECT * FROM `test` WHERE `somecolumn` = :p1");
    echo "query 1 is prepared fine\n";

    $sth2 = $pdo->prepare("SELECT * FROM `тест` WHERE `somecolumn` = :p1");
    echo "query 2 is prepared fine\n";
} catch (PDOException $e) {
    echo "failure: ".$e->getMessage()."\n";

Expected result:
query 1 is prepared fine
query 2 is prepared fine

Actual result:
query 1 is prepared fine
failure: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':p1' at line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-28 12:56 UTC] indeyets at gmail dot com
for some reason, bugtracker converted russian characters to entities. in my case there are real utf-8 characters
 [2006-04-29 21:48 UTC]
The PDO query parser has no idea that you're using utf-8, so it fails to parse the named placeholder.
The workaround is to not use utf-8 names for now.
 [2007-12-19 09:57 UTC] indeyets at gmail dot com
works for me on 5.2.4
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Feb 26 05:01:25 2024 UTC