Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #35565 : named :placeholders are not queried w/ MySQL
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 12th June 13:45
php-bugs@lists.php.net (capicrimm at gmail dot
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL



From: capiCrimm at gmail dot com
Operating system: GNU Debian Sarge
PHP version: 5CVS-2005-12-06 (snap)
PHP Bug Type: PDO related
Bug description: named laceholders are not queried w/ MySQL

Description:
------------
Using named and positional laceholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI

Reproduce code:
---------------
<?php

$conn = new PDO('mysql:dbname=testing;host=localhost;','root', '');

## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);

$name = 'val1';
$value = 'val2';
$stmt->execute();

foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as $table
){
print " {$table['one']}:{$table['two']} ";
}
?>

Expected result:
----------------
val1:val2

Actual result:
--------------
:

--
Edit bug report at http://bugs.php.net/?id=35565&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35565&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35565&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35565&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35565&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35565&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35565&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35565&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35565&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35565&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35565&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35565&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35565&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35565&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35565&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35565&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35565&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35565&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35565&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35565&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35565&r=mysqlcfg
  Reply With Quote


  sponsored links


2 12th June 14:47
iliaa
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL



ID: 35565
Updated by: iliaa@php.net
Reported By: capiCrimm at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:

What version of MySQL are you using?


Previous Comments:
------------------------------------------------------------------------

[2005-12-06 06:17:30] capiCrimm at gmail dot com

Description:
------------
Using named and positional laceholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI

Reproduce code:
---------------
<?php

$conn = new PDO('mysql:dbname=testing;host=localhost;','root', '');

## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);

$name = 'val1';
$value = 'val2';
$stmt->execute();

foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as
$table ){
print " {$table['one']}:{$table['two']} ";
}
?>

Expected result:
----------------
val1:val2

Actual result:
--------------
:


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


--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote
3 12th June 15:17
php-bugs@lists.php.net (capicrimm at gmail dot
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL


ID: 35565
User updated by: capiCrimm at gmail dot com
Reported By: capiCrimm at gmail dot com
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:

I'm running a .deb, ``mysql Ver 14.7 Distrib 4.1.12''.


Previous Comments:
------------------------------------------------------------------------

[2005-12-06 18:36:30] iliaa@php.net

What version of MySQL are you using?

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

[2005-12-06 06:17:30] capiCrimm at gmail dot com

Description:
------------
Using named and positional laceholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI

Reproduce code:
---------------
<?php

$conn = new PDO('mysql:dbname=testing;host=localhost;','root', '');

## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);

$name = 'val1';
$value = 'val2';
$stmt->execute();

foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as
$table ){
print " {$table['one']}:{$table['two']} ";
}
?>

Expected result:
----------------
val1:val2

Actual result:
--------------
:


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


--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote
4 12th June 15:17
iliaa
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL


ID: 35565
Updated by: iliaa@php.net
Reported By: capiCrimm at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:

Please try using this CVS snapshot:

http://snaps.php.net/php5.1-latest.tar.gz

For Windows:

http://snaps.php.net/win32/php5.1-win32-latest.zip

Seems to work in latest CVS using MySQL 4.1.14


Previous Comments:
------------------------------------------------------------------------

[2005-12-06 19:15:10] capiCrimm at gmail dot com

I'm running a .deb, ``mysql Ver 14.7 Distrib 4.1.12''.

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

[2005-12-06 18:36:30] iliaa@php.net

What version of MySQL are you using?

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

[2005-12-06 06:17:30] capiCrimm at gmail dot com

Description:
------------
Using named and positional laceholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI

Reproduce code:
---------------
<?php

$conn = new PDO('mysql:dbname=testing;host=localhost;','root', '');

## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);

$name = 'val1';
$value = 'val2';
$stmt->execute();

foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as
$table ){
print " {$table['one']}:{$table['two']} ";
}
?>

Expected result:
----------------
val1:val2

Actual result:
--------------
:


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


--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote
5 12th June 15:49
php-bugs@lists.php.net (capicrimm at gmail dot
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL


ID: 35565
User updated by: capiCrimm at gmail dot com
Reported By: capiCrimm at gmail dot com
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:

The CVS update did nothing. I tried downgrading to mysql
3.x and it didn't work. But upgrading to mysql5 did do the
job. Seems weird, but maybe it's only >4.1.14? I'll try
and compile PHP-CVS on another computer and see if the
error is still occuring.


Previous Comments:
------------------------------------------------------------------------

[2005-12-06 22:48:54] iliaa@php.net

Please try using this CVS snapshot:

http://snaps.php.net/php5.1-latest.tar.gz

For Windows:

http://snaps.php.net/win32/php5.1-win32-latest.zip

Seems to work in latest CVS using MySQL 4.1.14

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

[2005-12-06 19:15:10] capiCrimm at gmail dot com

I'm running a .deb, ``mysql Ver 14.7 Distrib 4.1.12''.

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

[2005-12-06 18:36:30] iliaa@php.net

What version of MySQL are you using?

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

[2005-12-06 06:17:30] capiCrimm at gmail dot com

Description:
------------
Using named and positional laceholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI

Reproduce code:
---------------
<?php

$conn = new PDO('mysql:dbname=testing;host=localhost;','root', '');

## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);

$name = 'val1';
$value = 'val2';
$stmt->execute();

foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as
$table ){
print " {$table['one']}:{$table['two']} ";
}
?>

Expected result:
----------------
val1:val2

Actual result:
--------------
:


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


--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote
6 12th June 16:15
tony2001
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL


ID: 35565
Updated by: tony2001@php.net
Reported By: capiCrimm at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)


Previous Comments:
------------------------------------------------------------------------

[2005-12-07 04:22:47] capiCrimm at gmail dot com

The CVS update did nothing. I tried downgrading to mysql
3.x and it didn't work. But upgrading to mysql5 did do the
job. Seems weird, but maybe it's only >4.1.14? I'll try
and compile PHP-CVS on another computer and see if the
error is still occuring.

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

[2005-12-06 22:48:54] iliaa@php.net

Please try using this CVS snapshot:

http://snaps.php.net/php5.1-latest.tar.gz

For Windows:

http://snaps.php.net/win32/php5.1-win32-latest.zip

Seems to work in latest CVS using MySQL 4.1.14

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

[2005-12-06 19:15:10] capiCrimm at gmail dot com

I'm running a .deb, ``mysql Ver 14.7 Distrib 4.1.12''.

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

[2005-12-06 18:36:30] iliaa@php.net

What version of MySQL are you using?

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

[2005-12-06 06:17:30] capiCrimm at gmail dot com

Description:
------------
Using named and positional laceholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI

Reproduce code:
---------------
<?php

$conn = new PDO('mysql:dbname=testing;host=localhost;','root', '');

## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);

$name = 'val1';
$value = 'val2';
$stmt->execute();

foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as
$table ){
print " {$table['one']}:{$table['two']} ";
}
?>

Expected result:
----------------
val1:val2

Actual result:
--------------
:


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


--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote
7 12th August 05:42
php-bugs@lists.php.net (leigh at eon dot com dot
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL


ID: 35565
Comment by: leigh at eon dot com dot au
Reported By: capiCrimm at gmail dot com
Status: No Feedback
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:

I have encountered this problem using PHP 5.1.2 with MySQL 4.1.12.
However, MySQL 5.0.18 returns the expected results.

I was unable to install the latest CVS copy of PHP 5.1, but might try
again later when I have more time.

<?php
$id = '1';

$conn = new PDO('mysql:dbname=test;host=localhost;','root','wo rksql');

# CREATE TABLE `testtable` ( `test_id` INT NOT NULL ,`test_data`
VARCHAR( 128 ) NOT NULL );
# INSERT INTO `testtable` ( `test_id` , `test_data` ) VALUES ( '1',
'test data 1' ), ( '2', 'test data 2' );

$query = $conn->prepare("SELECT * FROM testtable WHERE test_id=?");
$query->execute(array($id));

$results = $query->fetchAll(PDO::FETCH_ASSOC);

var_dump($results);
?>

MySQL 4.1.12 returns:
array(0) {
}

MySQL 5.0.18 returns:
array(1) {
[0]=>
array(2) {
["test_id"]=>
string(1) "1"
["test_data"]=>
string(11) "test data 1"
}
}


Previous Comments:
------------------------------------------------------------------------

[2005-12-15 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2005-12-07 04:22:47] capiCrimm at gmail dot com

The CVS update did nothing. I tried downgrading to mysql
3.x and it didn't work. But upgrading to mysql5 did do the
job. Seems weird, but maybe it's only >4.1.14? I'll try
and compile PHP-CVS on another computer and see if the
error is still occuring.

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

[2005-12-06 22:48:54] iliaa@php.net

Please try using this CVS snapshot:

http://snaps.php.net/php5.1-latest.tar.gz

For Windows:

http://snaps.php.net/win32/php5.1-win32-latest.zip

Seems to work in latest CVS using MySQL 4.1.14

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

[2005-12-06 19:15:10] capiCrimm at gmail dot com

I'm running a .deb, ``mysql Ver 14.7 Distrib 4.1.12''.

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

[2005-12-06 18:36:30] iliaa@php.net

What version of MySQL are you using?

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

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
http://bugs.php.net/35565

--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote
8 4th September 06:05
php-bugs@lists.php.net (jan_mentzel at gmx dot
External User
 
Posts: 1
Default #35565 : named :placeholders are not queried w/ MySQL


ID: 35565
Comment by: jan_mentzel at gmx dot de
Reported By: capiCrimm at gmail dot com
Status: No Feedback
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:

same problem here. This is quite a critical issue for me -
can't use my dev-box while pdo is broken.

gentoo (~x86)
gcc 4.1.1
mysql-4.1.21
apache-2.0.59
php-5.1.6 (r6)

Another strange thing is: On that box phpinfo() Configure
Command looks quite strange:

$ echo '<?php phpinfo() ?>' | php | grep configure
Configure Command => './configure' 'dummy' 'grep' 'ggrep'
$


But on an other box PDO placeholders are working as
expected:

gentoo (~x86)
gcc 3.4.3
mysql-4.1.21
apache-2.0.59 (r1)
php-5.1.6 (r6)

The phpinfo() "Configure Command" looks as expected as
well:

$ echo '<?php phpinfo() ?>' | php | grep configure
Configure Command
=> './configure' '--prefix=/usr/lib/php5' '--host=i586-pc-linux-gnu'
'--mandir=/usr/lib/php5/man'
[...]


Previous Comments:
------------------------------------------------------------------------

[2006-04-06 15:36:44] georg at howen dot de

I experienced the bug on PHP 5.1.2 on Linux (Linux infong 2.4 #3 SMP
Mon Feb 6 14:37:49 CET 2006 i686 unknown) on my providers webserver
with MySQL 5.0. Using the '?' placeholder instead named placeholders
seems to be a viable workaround.

Although everything works as expected on my local machine running
Windows XP, PHP 5.1.1 and MySQL 5.0.

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

[2006-03-10 08:47:45] leigh at eon dot com dot au

I have encountered this problem using PHP 5.1.2 with MySQL 4.1.12.
However, MySQL 5.0.18 returns the expected results.

I was unable to install the latest CVS copy of PHP 5.1, but might try
again later when I have more time.

<?php
$id = '1';

$conn = new PDO('mysql:dbname=test;host=localhost;','root','wo rksql');

# CREATE TABLE `testtable` ( `test_id` INT NOT NULL ,`test_data`
VARCHAR( 128 ) NOT NULL );
# INSERT INTO `testtable` ( `test_id` , `test_data` ) VALUES ( '1',
'test data 1' ), ( '2', 'test data 2' );

$query = $conn->prepare("SELECT * FROM testtable WHERE test_id=?");
$query->execute(array($id));

$results = $query->fetchAll(PDO::FETCH_ASSOC);

var_dump($results);
?>

MySQL 4.1.12 returns:
array(0) {
}

MySQL 5.0.18 returns:
array(1) {
[0]=>
array(2) {
["test_id"]=>
string(1) "1"
["test_data"]=>
string(11) "test data 1"
}
}

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

[2005-12-15 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2005-12-07 04:22:47] capiCrimm at gmail dot com

The CVS update did nothing. I tried downgrading to mysql
3.x and it didn't work. But upgrading to mysql5 did do the
job. Seems weird, but maybe it's only >4.1.14? I'll try
and compile PHP-CVS on another computer and see if the
error is still occuring.

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

[2005-12-06 22:48:54] iliaa@php.net

Please try using this CVS snapshot:

http://snaps.php.net/php5.1-latest.tar.gz

For Windows:

http://snaps.php.net/win32/php5.1-win32-latest.zip

Seems to work in latest CVS using MySQL 4.1.14

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

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
http://bugs.php.net/35565

--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666