Bug #33886 [Com]: PDO Prepared Statement fails if binding id (:blah) is used more then once.

From: Date: Wed, 06 Sep 2023 01:50:12 +0000
Subject: Bug #33886 [Com]: PDO Prepared Statement fails if binding id (:blah) is used more then once.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245337@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=33886&edit=1

 ID:                 33886
 Comment by:         egilmoreno at gmail dot com
 Reported by:        wb at pro-net dot co dot uk
 Summary:            PDO Prepared Statement fails if binding id (:blah)
                     is used more then once.
 Status:             Wont fix
 Type:               Bug
 Package:            PDO related
 Operating System:   FreeBSD 5.4-RELEASE-p2
 PHP Version:        5.0.4
 Block user comment: N
 Private report:     N

 New Comment:

Please, solution for this error:
<br />
<b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[01000]: Warning: 1265 Data
truncated for column 'id_client_user' at row 1 in
/home/sidecil/subdominios/cloud/apirest/v1/models/post.model.php:37
Stack trace:
#0 /home/sidecil/subdominios/cloud/apirest/v1/models/post.model.php(37):
PDOStatement-&gt;execute()
#1 /home/sidecil/subdominios/cloud/apirest/v1/controllers/post.controller.php(17):
PostModel::postData('users', Array)
#2 /home/sidecil/subdominios/cloud/apirest/v1/routes/services/post.php(37):
PostController::postData('users', Array)
#3 /home/sidecil/subdominios/cloud/apirest/v1/routes/routes.php(44):
include('/home/sidecil/s...')
#4 /home/sidecil/subdominios/cloud/apirest/v1/controllers/routes.controller.php(11):
include('/home/sidecil/s...')
#5 /home/sidecil/subdominios/cloud/apirest/v1/index.php(22): RoutesController-&gt;index()
#6 {main}
  thrown in <b>/home/sidecil/subdominios/cloud/apirest/v1/models/post.model.php</b> on
line <b>37</b><br />


Previous Comments:
------------------------------------------------------------------------
[2016-03-21 14:07:57] leif at neland dot dk

Would

$statement = $pdo->prepare("
    SET @sql_param=:php_param;
    SELECT ... FROM TAB where p=@sql_param or q=@sql_param
");
$statement->execute(array(':php_param' => $php_variable));


work?

------------------------------------------------------------------------
[2014-03-18 15:53:56] php at pineight dot com

Use of named placeholders is also not portable, as MySQL supports only positional placeholders, yet
PDO emulates it. Why does PDO emulate named placeholders on MySQL but not emulate repeated
placeholders? Otherwise, applications using PDO will end up littered with passive-aggressive
workarounds:

  $args[':skuid_bug33886'] = $args[':skuid'];
  $args[':supplierid_bug33886'] = $args[':supplierid'];

------------------------------------------------------------------------
[2005-07-27 16:20:41] wb at pro-net dot co dot uk

Fair enougth.

I will submit a note to the php manual about this.

Keep up the good work :)

------------------------------------------------------------------------
[2005-07-27 16:13:08] wez@php.net

It's not portable to rely on that.
You need to create three parameters and bind them separately.

------------------------------------------------------------------------
[2005-07-27 16:04:28] tony2001@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=33886


--
Edit this bug report at https://bugs.php.net/bug.php?id=33886&edit=1


Thread (8 messages)

« previous php.bugs (#245337) next »