MDB2 and single INSERT statement, prepare+execute or just query?
| From: | Michael Hanney | Date: | Fri, 21 May 2004 20:33:41 +0000 |
| Subject: | MDB2 and single INSERT statement, prepare+execute or just query? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-12674@lists.php.net to get a copy of this message | ||
Hello,
I am ditching my own DB abstraction class in favour of MDB2.
When I need to do a sinlge INSERT, should I use MDB2_Driver_Common->prepare
like this..
$prep = $this->mdb2->prepare('INSERT INTO test (test_id, name) values
(?,?)', $types);
$result = $this->mdb2->executeParams($prep, $types, $data);
OR should I simply use MDB2_Driver_Common->query($sql)..
$res = $this->mdb2->query($sql);
where the $sql contains the pre-formatted INSERT statement? What I really
want to know is - does the prepare method offer any compatibility advantage
(escaping depending on types?),
or is it just for speeding up multiple inserts i.e. prepare once, execute
many. The docs explain how, but not always why. Inserts don't happen very
often in my apps so compatibility accross multiple dbs is more important to
me than speed.
Thanks a lot.
Michael.