RE: [PEAR] Placeholder queries
| From: | Lukas Smith | Date: | Thu, 10 Apr 2003 14:01:10 +0000 |
| Subject: | RE: [PEAR] Placeholder queries | ||
| References: | 1 | Groups: | php.pear.dev php.pear.general |
| Request: | Send a blank email to pear-dev+get-15096@lists.php.net to get a copy of this message | ||
> From: Jeroen Houben [mailto:jeroen@terena.nl]
> Sent: Thursday, April 10, 2003 3:55 PM
> >>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
> >
> >>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 ?
> >>
> >>
> >
> >PEAR::DB also has "!" for values what will directly be used (like
> >integers).
> >Well I have been banging my head on that one a bit. Unfortunately
nobody
> >ever replied to my questions on the PEAR mailinglists.
> >
> >Basically PEAR::DB splits things up in 3 different types:
> >1) Data that needs to be quoted
> >2) Data that can be left as is
> >3) LOBs
> >
> >This does not sufficiently abstract things however. MDB supports
other
> >datatypes as well that might need special attention (like
timestamps).
> >
> >As such MDB has the following datatypes:
> >1) Text data type
> >2) Boolean data type
> >3) Integer data type
> >4) Decimal data type
> >5) Float data type
> >6) Date data type
> >7) Time data type
> >8) Time stamp data type
> >9) Binary Large object (file) data types
> >10) Character Large object (file) data types
> >
> >6-8 can be combined into one datatype for this purposes.
> >
> >So we could use ? for text, ! for integers and & for blobs. What
happens
> >with the other datatypes?
> >
> >
> It's ok to have placeholders just for a selection of types isn't it?
Or
> is that bad practice? I could see that for MDB a placeholder for LOBs
> would be very useful, because the LOB will then be created behind the
> scenes and the user does not need to worry about it.
Well I would prefer a more complete solution.
But yes it might be worthwhile to have a solution just for lob's as they
are a bit painful to use atm.
Regards,
Lukas