This is the first post in a long, long while! And I mean LONG!
I’ve been writing my experiences on another place, but I actually stopped writing there also. Why?.. A situation was created that was telling me “what for?!”Now I’m slowly getting back, and I will explain why in another post, who knows when?!
Getting back to the reason why I’m posting this.
I found a solution to all of you out there, who have nothing better to do then to use steroids for your fingers, in order to type faster and more acurrately.
It concerns the Zend Platform. Precisely, the Db class for MySQLi.
If you try to get BLOB records using Zend_Db_Adapter_Mysqli as adapter, then you’re in trouble. Apache crashes when you do fetchAll. When you do fetchRow, you see weird characters floating around.
The reason is pretty simple. Overflow! In order to solve this, you need to go into Zend/Db/Statement/Mysqli.php and edit function closeCursor (around line 100) so that you will have something like this
if (!$this->_stmt) {
return false;
}
// ANDREI
$this->_stmt->free_result();
$this->_stmt->close();
return true;
Then in function execute, around line 160
if (!$this->_stmt) {
return null;
}
// execute the statement
$return = $this->_stmt->execute();
// ANDREI
$this->_stmt->store_result();
// retain metadata
Afterwards, around line 210, still inside execute, change into return $return;
This doesn’t concern only Zend Platform users, but anyone who makes use of mysqli_stmt_* functions. When working with (returning) Blobs, always store the result, then do the bindings and fetching!
Next time, Blobs will be ok!
Happy coding, and sorry for all of you who expected something more… fun, social, cool…
Categories:
