If all these timing loops aren’t in Eto, most certainly. Every query to the database is getting the timing loop, since all the functions use the query() function internally.
This is what I changed in dbapi.mysql.class.inc.php:
added a rudimentary error function at the end of the class:
function errorMsg($msg="Database Error") {
echo $msg;
}
Made the timing section into a conditional block and used the new errorMsg function in connect:
function connect($host='',$dbase='', $uid='',$pwd='',$persist=0){
$uid = $uid ? $uid:$this->config['user'];
$pwd = $pwd ? $pwd:$this->config['pass'];
$host = $host ? $host:$this->config['host'];
$dbase = $dbase ? $dbase:$this->config['dbase'];
if(@!$this->conn = ($persist ? mysql_pconnect($host, $uid, $pwd):mysql_connect($host, $uid, $pwd))) {
$this->errorMsg("Failed to create the database connection!");
exit;
} else {
$dbase = str_replace('`','',$dbase); // remove the `` chars
if(!@mysql_select_db($dbase)) {
$this->errorMsg("Failed to select the database."); // error message
exit;
}
// check for modx object
if(is_object($modx)) {
$tend = $modx->getMicroTime();
$totaltime = $tend-$tstart;
if($modx->dumpSQL) {
$modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", $totaltime)."</fieldset><br />";
}
$this->queryTime = $this->queryTime+$totaltime;
}
$this->isConnected = true;
}
}
In query, likewise:
function query($sql) {
if(empty($this->conn)||!is_resource($this->conn)) {
$this->connect();
}
if(is_object($modx)) { // check for modx object
$tstart = $modx->getMicroTime();
}
if(!$result = @mysql_query($sql, $this->conn)) {
this->errorMsg("Execution of a query to the database failed."); //error message
} else {
if(is_object($modx)) { // check for modx object
$tend = $modx->getMicroTime();
$totaltime = $tend-$tstart;
$modx->queryTime = $modx->queryTime+$totaltime;
if($modx->dumpSQL) {
$modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($this->executedQueries+1)." - ".sprintf("%2.4f s", $totaltime)."</legend>".$sql."</fieldset><br />";
}
$modx->executedQueries = $modx->executedQueries+1;
}
return $result;
}
}
And in getRow I changed the error message into a default:
function getRow($ds,$mode='assoc'){
if($ds) {
if($mode=='assoc') {
return mysql_fetch_assoc($ds);
}
elseif($mode=='num') {
return mysql_fetch_row($ds);
}
elseif($mode=='both') {
return mysql_fetch_array($ds, MYSQL_BOTH);
}
else {
return mysql_fetch_row($ds); // default to numeric
}
}
}