I was working on writing an admin module and had set up my own error handler and kept on seeing
Notice: Object of class queryFactoryResult could not be converted to int unknown 0
This was showing on every single admin page, and when I turned on the E_ALL in the user pages, it was at the bottom of each of those pages too, although it claimed it was happening in application_bottom.php on line 13. When I commented out the session_write_close() line, it continued to appear but with the frustratingly familiar unknown 0;
I will not bore you to tears with the details of getting it figured out, I'll just share the cause and the solution.
Cause:
When you run anything through the Execute() function in query_factory.php, it creates an object. That object contains the resource id among other things. The pertinent line, which occurs more than once, is:
$zp_db_resource = @mysql_query($zf_sql, $this->link);
After an error check, $obj->resource is set to $zp_db_resource.
The problem occurs when the query doesn't return a resource id.
This happens whenever a non-recordset query is made, like update or delete--instead of returning a resource id, the function returns "true" to show that the query executed successfully.
Since $obj->resource has already been set with a resource during previous queries, what happens is that the code overwrites whatever is currently in there with 1 (for "true"), and produces the notice since the variable type is being changed.
Solution:
Rather than write a function especially for non-recordset queries, the answer is to add a few lines of code to the query factory.
After every appearance of the following lines:add this statemnt:Code:$zp_db_resource = @mysql_query($zf_sql, $this->link); if (!$zp_db_resource) $this->set_error(@mysql_errno(),@mysql_error());
What it does is simply unset the object and exits the function if the response is not a resource.Code:if(!is_resource($zp_db_resource)){ $obj = null; return; }
I hope this solution and explanation is helpful.
Bookmarks