note 70713 added to function.pdostatement-execute
| From: | inghamn at bloomington dot in dot gov | Date: | Tue, 24 Oct 2006 20:53:46 +0000 |
| Subject: | note 70713 added to function.pdostatement-execute | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119084@lists.php.net to get a copy of this message | ||
Just a note, I'm currently using 5.1.6. After debugging for a good amount of time, I've
realized that the $array cannot be an associative array.
For instance, the following code will fail on the execute.
<?php
$fields = array();
$fields['name'] = "Someone";
$query = $PDO->prepare("insert table set name=?");
$query->execute($fields);
?>
For my code, I had to convert the $fields array into a non-associative array. Something like this:
<?php
$fields = array();
$fields['name'] = "Someone";
$values = array();
foreach($fields as $value) { $values[] = $value; }
$query = $PDO->prepare("insert table set name=?");
$query->execute($values);
?>
----
Server IP: 66.163.161.117
Probable Submitter: 192.188.224.2
----
Manual Page -- http://www.php.net/manual/en/function.pdostatement-execute.php
Edit -- https://master.php.net/note/edit/70713
Del: integrated -- https://master.php.net/note/delete/70713/integrated
Del: useless -- https://master.php.net/note/delete/70713/useless
Del: bad code -- https://master.php.net/note/delete/70713/bad+code
Del: spam -- https://master.php.net/note/delete/70713/spam
Del: non-english -- https://master.php.net/note/delete/70713/non-english
Del: in docs -- https://master.php.net/note/delete/70713/in+docs
Del: other reasons-- https://master.php.net/note/delete/70713
Reject -- https://master.php.net/note/reject/70713
Search -- https://master.php.net/manage/user-notes.php