Code was attempting to handle this case by asking the result object for its db so we can ask for the affected row count -- obviously that doesn't do so good when the result is not an object.
Changed Database::sourceStream() to send itself as the second parameter to the result-handling callback, so the callback knows which DB to check.
$cmd = $this->replaceVars( $cmd );
$res = $this->query( $cmd, __METHOD__ );
if ( $resultCallback ) {
- call_user_func( $resultCallback, $res );
+ call_user_func( $resultCallback, $res, $this );
}
if ( false === $res ) {
}
}
-function sqlPrintResult( $res ) {
+function sqlPrintResult( $res, $db ) {
if ( !$res ) {
// Do nothing
- } elseif ( $res->numRows() ) {
+ } elseif ( is_object( $res ) && $res->numRows() ) {
while ( $row = $res->fetchObject() ) {
print_r( $row );
}
} else {
- $affected = $res->db->affectedRows();
+ $affected = $db->affectedRows();
echo "Query OK, $affected row(s) affected\n";
}
}