[PHP-BUG] Bug #65149 [NEW]: MySQL + EMULATE_PREPARES = false cause HY093 error with non unique parameters

2013-06-27 Thread ipernet at gmail dot com
From: ipernet at gmail dot com
Operating system: Slackware 13 x64
PHP version:  5.4.16
Package:  PDO related
Bug Type: Bug
Bug description:MySQL + EMULATE_PREPARES = false cause HY093 error with non 
unique parameters

Description:

PHP:
5.4.16

PDO Client API version:
mysqlnd 5.0.10 - 20111026

MySQL:
5.5.18-log (same on 5.6.10-log)

When using "PDO::ATTR_EMULATE_PREPARES => false" with a PDO prepared
statement, 
the query fails if it refers to the same named parameter more than once.

Work OK with "PDO::ATTR_EMULATE_PREPARES => true"



Test script:
---
CREATE TABLE IF NOT EXISTS `test` (
  `id` int(10) unsigned NOT NULL,
  `date` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--


* Common test code *


$pdo = new PDO('mysql:host=;dbname=', '', '',
array(PDO::ATTR_EMULATE_PREPARES => false));


**
* Test 1 *
**
 
$query  =   $pdo->prepare('INSERT INTO test(id, date) VALUES(:id, :date) ON
DUPLICATE KEY UPDATE date = :date');

$query->bindValue(':id', 5);
$query->bindValue(':date', time());

if( ! $query->execute())
var_dump($query->errorInfo());


**
* Test 2 *
**

$query  =   $pdo->prepare('INSERT INTO test(id, date) VALUES(:date, 
:date)');

$query->bindValue(':date', time());

if( ! $query->execute())
var_dump($query->errorInfo());



**
* Test 3 *
**

$query  =   $pdo->prepare('INSERT INTO test(id, date) VALUES(:date,
:date2)');

$query->bindValue(':date', time());
$query->bindValue(':date2', time());

if( ! $query->execute())
var_dump($query->errorInfo());

Expected result:

No error and an inserted row in DB for both test 1, 2 and 3.

Actual result:
--
Test 1 & 2 don't work and return:

array(3) { [0] => string(5) "HY093" [1] => NULL [2] => NULL } 

Test 3 works as it does not refer to the same named parameter more than
once.

- If you change "PDO::ATTR_EMULATE_PREPARES" to "true", all tests work
fine.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=65149&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65149&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65149&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=65149&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=65149&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=65149&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65149&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=65149&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=65149&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=65149&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=65149&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65149&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65149&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=65149&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65149&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=65149&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=65149&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=65149&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65149&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65149&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65149&r=mysqlcfg



Bug #65149 [Opn->Csd]: MySQL + EMULATE_PREPARES = false cause HY093 error with non unique parameters

2013-06-27 Thread ipernet at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=65149&edit=1

 ID: 65149
 User updated by:ipernet at gmail dot com
 Reported by:ipernet at gmail dot com
 Summary:MySQL + EMULATE_PREPARES = false cause HY093 error
 with non unique parameters
-Status: Open
+Status: Closed
 Type:   Bug
 Package:PDO related
 Operating System:   Slackware 13 x64
 PHP Version:5.4.16
 Block user comment: N
 Private report: N

 New Comment:

Duplicate with #64875


Previous Comments:

[2013-06-27 17:34:56] ipernet at gmail dot com

Description:

PHP:
5.4.16

PDO Client API version:
mysqlnd 5.0.10 - 20111026

MySQL:
5.5.18-log (same on 5.6.10-log)

When using "PDO::ATTR_EMULATE_PREPARES => false" with a PDO prepared statement, 
the query fails if it refers to the same named parameter more than once.

Work OK with "PDO::ATTR_EMULATE_PREPARES => true"



Test script:
---
CREATE TABLE IF NOT EXISTS `test` (
  `id` int(10) unsigned NOT NULL,
  `date` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--


* Common test code *


$pdo = new PDO('mysql:host=;dbname=', '', '', 
array(PDO::ATTR_EMULATE_PREPARES => false));


**
* Test 1 *
**
 
$query  =   $pdo->prepare('INSERT INTO test(id, date) VALUES(:id, :date) ON 
DUPLICATE KEY UPDATE date = :date');

$query->bindValue(':id', 5);
$query->bindValue(':date', time());

if( ! $query->execute())
var_dump($query->errorInfo());


**
* Test 2 *
**

$query  =   $pdo->prepare('INSERT INTO test(id, date) VALUES(:date, 
:date)');

$query->bindValue(':date', time());

if( ! $query->execute())
var_dump($query->errorInfo());



**
* Test 3 *
**

$query  =   $pdo->prepare('INSERT INTO test(id, date) VALUES(:date, 
:date2)');

$query->bindValue(':date', time());
$query->bindValue(':date2', time());

if( ! $query->execute())
var_dump($query->errorInfo());

Expected result:

No error and an inserted row in DB for both test 1, 2 and 3.

Actual result:
--
Test 1 & 2 don't work and return:

array(3) { [0] => string(5) "HY093" [1] => NULL [2] => NULL } 

Test 3 works as it does not refer to the same named parameter more than once.

- If you change "PDO::ATTR_EMULATE_PREPARES" to "true", all tests work fine.







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


[PHP-BUG] Bug #64132 [NEW]: PDO/MySQL query fails when binding a float value with data type PDO::PARAM_INT

2013-02-02 Thread ipernet at gmail dot com
From: ipernet at gmail dot com
Operating system: Slackware 13 x64
PHP version:  5.4.11
Package:  PDO related
Bug Type: Bug
Bug description:PDO/MySQL query fails when binding a float value with data type 
PDO::PARAM_INT

Description:

PHP:
5.4.11

PDO Client API version:
mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $


MySQL:
5.5.18-log

Using a PDO prepared statement to insert a new row, the query fails if a
float 
value is passed for a token and this token use PDO::PARAM_INT as data type.

Test script:
---
CREATE TABLE IF NOT EXISTS `test` (
  `kms` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
---


$query  =   $dbh->prepare('INSERT INTO test(kms) VALUES(:kms)');

$query->bindValue(':kms',  1.25, PDO::PARAM_INT);
$query->execute();

var_dump($query->errorInfo());

Expected result:

- "1" should be inserted in the table
- Query should execute properly and do not lead to a SQL parsing error.

Actual result:
--
array(3) {
  [0] =>
  string(5) "21S01"
  [1] =>
  int(1136)
  [2] =>
  string(47) "Column count doesn't match value count at row 1"
}

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64132&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64132&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64132&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=64132&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=64132&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=64132&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64132&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=64132&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=64132&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=64132&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=64132&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64132&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64132&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=64132&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64132&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=64132&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=64132&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=64132&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64132&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64132&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64132&r=mysqlcfg



Bug #64132 [Opn]: PDO/MySQL query fails when binding a float value with data type PDO::PARAM_INT

2013-02-11 Thread ipernet at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=64132&edit=1

 ID: 64132
 User updated by:ipernet at gmail dot com
 Reported by:ipernet at gmail dot com
 Summary:PDO/MySQL query fails when binding a float value
 with data type PDO::PARAM_INT
 Status: Open
 Type:   Bug
 Package:PDO related
 Operating System:   Slackware 13 x64
 PHP Version:5.4.11
 Block user comment: N
 Private report: N

 New Comment:

Important note:

This only happens if the set locale use a comma as decimal separator. 

Please add "setlocale(LC_ALL, 'fr_FR');" at the beginning of the test code to 
reproduce. 

This is still an unexpected behavior.


Previous Comments:
----
[2013-02-02 15:14:14] ipernet at gmail dot com

Description:

PHP:
5.4.11

PDO Client API version:
mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $ 

MySQL:
5.5.18-log

Using a PDO prepared statement to insert a new row, the query fails if a float 
value is passed for a token and this token use PDO::PARAM_INT as data type.

Test script:
---
CREATE TABLE IF NOT EXISTS `test` (
  `kms` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
---


$query  =   $dbh->prepare('INSERT INTO test(kms) VALUES(:kms)');

$query->bindValue(':kms',  1.25, PDO::PARAM_INT);
$query->execute();

var_dump($query->errorInfo());

Expected result:

- "1" should be inserted in the table
- Query should execute properly and do not lead to a SQL parsing error.

Actual result:
--
array(3) {
  [0] =>
  string(5) "21S01"
  [1] =>
  int(1136)
  [2] =>
  string(47) "Column count doesn't match value count at row 1"
}






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