note 71929 added to function.pdostatement-execute
| From: | VolGas at osu1 dot php dot net | Date: | Sat, 23 Dec 2006 06:38:47 +0000 |
| Subject: | note 71929 added to function.pdostatement-execute | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120873@lists.php.net to get a copy of this message | ||
An array of insert values (named parameters) don't need the prefixed colon als key-value to
work.
<?php
/* Execute a prepared statement by passing an array of insert values */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour');
// instead of:
// $sth->execute(array(':calories' => $calories, ':colour' =>
$colour));
// this works fine, too:
$sth->execute(array('calories' => $calories, 'colour' => $colour));
?>
This allows to use "regular" assembled hash-tables (arrays).
That realy does make sense!
----
Server IP: 217.160.72.57
Probable Submitter: 217.173.147.8
----
Manual Page -- http://www.php.net/manual/en/function.pdostatement-execute.php
Edit -- https://master.php.net/note/edit/71929
Del: integrated -- https://master.php.net/note/delete/71929/integrated
Del: useless -- https://master.php.net/note/delete/71929/useless
Del: bad code -- https://master.php.net/note/delete/71929/bad+code
Del: spam -- https://master.php.net/note/delete/71929/spam
Del: non-english -- https://master.php.net/note/delete/71929/non-english
Del: in docs -- https://master.php.net/note/delete/71929/in+docs
Del: other reasons-- https://master.php.net/note/delete/71929
Reject -- https://master.php.net/note/reject/71929
Search -- https://master.php.net/manage/user-notes.php