".mysql_error()."
"); } /** Internal function to debug a MySQL query.\n * Show the query and output the resulting table if not NULL. * @param $debug The parameter passed to query() functions. Can be boolean or -1 (default). * @param $query The SQL query to debug. * @param $result The resulting table of the query, if available. */ function debug($debug, $query, $result = NULL) { if ($debug === -1 && $this->defaultDebug === false) return; if ($debug === false) return; $reason = ($debug === -1 ? "Default Debug" : "Debug"); $this->debugQuery($query, $reason); if ($result == NULL) echo "Number of affected rows: ".mysql_affected_rows()."
"; else $this->debugResult($result); } /** Internal function to output a query for debug purpose.\n * Should be followed by a call to debugResult() or an echo of "". * @param $query The SQL query to debug. * @param $reason The reason why this function is called: "Default Debug", "Debug" or "Error". */ function debugQuery($query, $reason = "Debug") { $color = ($reason == "Error" ? "red" : "orange"); echo "". "$reason: ". "".htmlentities($query)."
"; } /** Internal function to output a table representing the result of a query, for debug purpose.\n * Should be preceded by a call to debugQuery(). * @param $result The resulting table of the query. */ function debugResult($result) { echo "| ".$tables[$i]["name"]." | "; echo ""; echo ""; for ($i = 0; $i <= $nbFields; $i++) echo "".$fields[$i]." | "; echo ""; // END HEADER while ($row = mysql_fetch_array($result)) { echo "
|---|
| ".htmlentities($row[$i])." | "; echo "