![]() |
![]() |
|
Current Projects: PHP on XP Guide — NFO Viewer — Easy Reflections — Photon Storm — HotWire — FileGlider
Wednesday, April 18. 2007PDO SQLite support just doesn't work fully?Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
My suggestion is to step back and try something simple:
$stmt = $db->prepare('INSERT INTO Test (name, data) VALUES (?,?)'); $stmt->execute(array($name, file_get_contents($pic_data_file))); You get no performance benefit from the LOB APIs if the underlying database doesn't actually have LOB APIs, as is the case here. You should also note that sqlite is typeless in the same way that PHP is, so inserting data as strings is no different from inserting it any other way. Hope that helps, and I also hope that you take a few extra minutes to file or update bug reports on this, because the people that go to fix things don't read your blog on a daily basis to find out what needs to be done. (google for "don't blog bugs").
I didn't want to post it as a bug, because I believed the error to be BTUATK! But as your code given above doesn't work either I have indeed put in a fresh bug report for this, with as much information as possible: http://bugs.php.net/bug.php?id=41135
Hmm...
The very same code works for me on Windows XP, PHP5.2.1 and SQLite 3: $stmt = $conn->prepare("UPDATE books SET coverMime=?, coverImage=? WHERE id=$book[id]"); $cover = fopen($_FILES['cover']['tmp_name'], 'rb'); $stmt->bindValue(1, $_FILES['cover']['type']); $stmt->bindParam(2, $cover, PDO::PARAM_LOB); The only thing that does not work es expected is this bug: http://bugs.php.net/bug.php?id=40913
Would you mind emailing me the SQLite database file? It has to be an inconsistency between the SQLite files themselves if that code works for you, on an exact same set-up, but not here.
I had a LAMP stack a month or two ago (ubuntu) where everytime I'd perform an insert with PDO, it would just spit in garbage data. That was a lot of fun.
I believe it crops the data to the first \0 byte.
The ugly workaround is not to use bound parameters ... $pic_data = 'X'.$db->quote(bin2hex($pic_data)); $stmt = $db->prepare('INSERT INTO Test (name, data) VALUES (?,'.$pic_data.')'); $stmt->bindParam(1, $name, PDO::PARAM_STR, 60); $stmt->execute();
Brilliant idea. Thanks for very interesting article. btw. I really enjoyed reading all of your articles. It’s interesting to read ideas, and observations from someone else’s point of view… makes you think more. Keep up the good work. Greetings
Interesting ... it remembers me at: "is it a bug or a feature?". is there any new informations about that topic?
|
QuicksearchCategoriesMy AS3 Blog
Photon Storm Great PHP links
C7Y PHP Podcast CorePHP is hosted by |