From 43652dbc985a3a91c5e2c8fb1c621bea9a1e06ce Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 10 Sep 2005 16:39:21 +0000 Subject: [PATCH] Document new bindValue() method. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@195721 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../pdo/functions/PDOStatement-bindParam.xml | 10 +- .../pdo/functions/PDOStatement-bindValue.xml | 136 ++++++++++++++++++ 2 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 reference/pdo/functions/PDOStatement-bindValue.xml diff --git a/reference/pdo/functions/PDOStatement-bindParam.xml b/reference/pdo/functions/PDOStatement-bindParam.xml index b23242f527..98adb3cf47 100644 --- a/reference/pdo/functions/PDOStatement-bindParam.xml +++ b/reference/pdo/functions/PDOStatement-bindParam.xml @@ -1,5 +1,5 @@ - + @@ -20,8 +20,11 @@ &warn.experimental.func; - Binds a parameter to a corresponding named or question mark placeholder - in the SQL statement that was use to prepare the statement. + Binds a PHP variable to a corresponding named or question mark placeholder + in the SQL statement that was use to prepare the statement. Unlike + PDOStatement::bindValue, the variable is bound as a + reference and will only be evaluated at the time that + PDOStatement::execute is called. Most parameters are input parameters, that is, parameters that are used @@ -173,6 +176,7 @@ print("After pureeing fruit, the colour is: $colour"); PDO::prepare PDOStatement::execute + PDOStatement::bindValue diff --git a/reference/pdo/functions/PDOStatement-bindValue.xml b/reference/pdo/functions/PDOStatement-bindValue.xml new file mode 100644 index 0000000000..cf05903bed --- /dev/null +++ b/reference/pdo/functions/PDOStatement-bindValue.xml @@ -0,0 +1,136 @@ + + + + + + PDOStatement::bindValue + + Binds a value to a parameter + + + + &reftitle.description; + + boolPDOStatement::bindValue + mixedparameter + mixedvalue + intdata_type + + &warn.experimental.func; + + Binds a value to a corresponding named or question mark placeholder + in the SQL statement that was use to prepare the statement. + + + + + &reftitle.parameters; + + + + parameter + + + Parameter identifier. For a prepared statement using named + placeholders, this will be a parameter name of the form + :name. For a prepared statement using + question mark placeholders, this will be the 1-indexed position of + the parameter. + + + + + value + + + The value to bind to the parameter. + + + + + data_type + + + Explicit data type for the parameter using the PDO_PARAM_* + constants. + + + + + + + + + &reftitle.examples; + Execute a prepared statement with named placeholders + +prepare('SELECT name, colour, calories + FROM fruit + WHERE calories < :calories AND colour = :colour'); +$sth->bindValue(':calories', $calories, PDO_PARAM_INT); +$sth->bindValue(':colour', $colour, PDO_PARAM_STR); +$sth->execute(); +?> +]]> + + + + Execute a prepared statement with question mark placeholders + +prepare('SELECT name, colour, calories + FROM fruit + WHERE calories < ? AND colour = ?'); +$sth->bindValue(1, $calories, PDO_PARAM_INT); +$sth->bindValue(2, $colour, PDO_PARAM_STR); +$sth->execute(); +?> +]]> + + + + + + + + &reftitle.seealso; + + + PDO::prepare + PDOStatement::execute + PDOStatement::bindParam + + + + + + +