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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sexavet94 at gmail dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Mar 19 09:01:30 2024 UTC