Placeholder queries
| From: | Jeroen Houben | Date: | Thu, 10 Apr 2003 12:33:30 +0000 |
| Subject: | Placeholder queries | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4778@lists.php.net to get a copy of this message | ||
Hi Lukas,
In this month's PHP magazine I read that with PEAR::DB you can do placeholder queries like this:
$file = '/tmp/image.png';
$sql = 'INSERT INTO mytable (id, myblob) VALUES (?,&)';
$id = $conn->nextId('mytable_id');
$conn->query($sql, array($id, $file));
I was familiar with prepared queries using a questionmark. What was new to me, and perhaps to a lot of people, is that the '&' symbol will be replaced with the contents of the file. Very cool. Does this (or something similar) also work in PEAR::MDB ?
Jeroen