This page is really not clear for the function: http://www.php.net/manual/en/pdostatement.execute.php
I'm not exactly sure why I would bindParam as oppose to just passing in an array. With bindParam, I'll have to specify the type.
So my question woul开发者_如何学JAVAd be, if I just do $stmt->execute(array("somevalue", b'somebinarydata', 10203, 201.3));
, would the types be automatically recognized? Is there anything I have be aware of?
Thanks.
So my question would be, if I just do $stmt->execute(array("somevalue", b'somebinarydata', 10203, 201.3));, would the types be automatically recognized?
The answer is No, The PHP manual states:
An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as
PDO::PARAM_STR
.
the page stating the entity PDO::PARAM_STR
states:
Represents the SQL CHAR, VARCHAR, or other string data type.
source: http://www.php.net/manual/en/pdo.constants.php
As it says in the doc, if you want to specify type you do that beforehand, for example:
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
Example
精彩评论