Hi,

Since I've gotten no answer from the maintainer of the DBD::mysqlPP driver,
I thought I'd forward my question here, so that if anyone here has an answer
or hint they might tell me.

TIA

--
Aigars Grins

-----Original Message-----
From: Aigars Grins [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 15:50
To: [EMAIL PROTECTED]
Subject: Question about the DBD::mysqlPP DBI driver


Hi,

I've just installed a new version of OpenBSD 3.2 and noticed that the
customary DBD::mysql driver in the ports tree has been replacted by the
DBD::mysqlPP driver. Ok, I thought, I don't mind. Now I'm trying to figure
out the differences. I've found one problem situation and wonder if you
might want to help me on the way of understanding how to solve it.


I want to insert a BLOB into a MySQL column. If we assume that this is how
it looks:

CREATE TABLE test_blobs (
        id   INT NOT NULL PRIMARY_KEY AUTO_INCREMENT,
        data BLOB
);

Then I thought about doing something like:

...
$sth = $dbh->prepare("INSERT INTO test_blobs");
$sth->execute();
$id = $dbh->{"mysql_insertid"};
$sth = $dbh->prepare("UPDATE test_blobs SET data = ? WHERE id = ?");
$sth->execute($id, $data);
...

But I don't get this to work, if the $data variable contains "?" characters.
I've looked at your code and understand why it doesn't, but I don't
understand of how to solve this problem properly.

The only work-around that I can figure out is something like:

...
$sth = $dbh->prepare("INSERT INTO test_blobs");
$sth->execute();
$id = $dbh->{"mysql_insertid"};
$sth = $dbh->prepare("UPDATE test_blobs SET data = ".$dbh->quote($data)."
WHERE id = ".$id);
$sth->STORE("NUM_OF_PARAMS" => 0);
$sth->execute();
...

Although this seems to work it's _very_ ugly..

Can you help me out?

TIA

--
Aigars Grins

Reply via email to