php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38389 What is the default type of bindParam(), bindValue() and execute(array) ? (PDO)
Submitted: 2006-08-08 21:59 UTC Modified: 2007-08-17 17:02 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: baldurien at bbnwn dot eu Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2006-08-08 21:59 UTC] baldurien at bbnwn dot eu
Description:
------------
I was wondering what is the default type of parameter when none is set? 

Reproduce code:
---------------
If I run that code :

$dbh = new PDO(
  'mysql:host=localhost;dbname=xxx', 'xxx', 'xxx');
$stmt = $dbh->prepare('SELECT ? FROM DUAL WHERE 1 = ?');

var_dump($stmt->execute(array('aa\'aa', 'aaa')));

This dump true, meaning that 'aaa' was casted to a string and that the actual query looks like this in mySQL :

SELECT 'aa''aa' FROM DUAL WHERE 1 = 'aaa'

Expected result:
----------------
The documentation should indicate that when no type is provided (while calling bindParam(), bindValue(), or execute()), PDO::PARAM_STRING is used. 

Actual result:
--------------
Neither bindParam(), bindValue() or execute() speak of a default type, nor the main page of PDO (http://fr.php.net/manual/en/ref.pdo.php) describe it. Thus, we could expect anything from the driver (like casting variable into integer instead of string).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 17:02 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Defaults to PHP native type."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 12:01:33 2025 UTC