php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73932 Bind value not working in MySQL GROUP_CONCAT - Separator
Submitted: 2017-01-14 10:18 UTC Modified: 2020-12-10 11:37 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sexavet94 at gmail dot com Assigned:
Status: Not a bug Package: PDO MySQL
PHP Version: 7.0.14 OS: Linux
Private report: No CVE-ID: None
 [2017-01-14 10:18 UTC] sexavet94 at gmail dot com
Description:
------------
Hello.

There is a bug in PDO's MySQL driver.

It is necessary to write SQL query like this:

SELECT GROUP_CONCAT( title SEPARATOR '\'' ) FROM `tblNews` GROUP BY `date`


I bind value to the separator by PDO but it doesn't work.



Test script:
---------------
<?php

// ...

$this->connection = new PDO('mysql:host=' . $configurations['host'] . ';dbname=' . $configurations['database'] . '; charset=utf8', $configurations['user'], $configurations['password']);

$sth = $this->connection->prepare("SELECT GROUP_CONCAT( title SEPARATOR ? ) FROM `tblNews` GROUP BY `date`");

$sth->bindValue(1 , ':');

$sth->execute();

var_dump($sth->fetch());


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-14 18:39 UTC] cmb@php.net
*At least* with regard to native prepared statements this is not a
PHP/PDO issue, but rather a MySQL problem, see
<https://bugs.mysql.com/bug.php?id=17832>.
 [2020-12-10 11:37 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2020-12-10 11:37 UTC] nikic@php.net
This works fine with emulated prepared statements. It does not work with native prepared statements, but as @cmb pointed out, this is a MySQL limitation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC