/** * */ private static function logQuery($query, $startTime = false, $executionStatus = true, $linhas = '0', $errorMessage = '', $class = '', $db = false) { $backTrace = debug_backtrace(); array_shift($backTrace); $backTrace = array_reverse($backTrace); $backtraceOutput = '<br>'; foreach ($backTrace as $key => $bt) { if ($bt['file'] === __FILE__) { continue; } // foreach ( $bt['args'] as &$arg ) if ( gettype ( $arg ) === 'object' ) $arg = "Object of " . get_class($arg) ; foreach ($bt['args'] as &$arg) { $rand = md5(mt_rand()); if (gettype($arg) === 'object') { $arg = "<a style=\"cursor:pointer\" onclick=\"var el=document.getElementById('{$rand}');if (el.style.display==='none'){el.style.display='block'}else{el.style.display='none'}\"><span style=\"color:#088\">Object of:</span> " . get_class($arg) . "</a>" . "<div id=\"{$rand}\" style=\"display:none;border:1px solid #000;width:600px;height:150px;overflow:scroll;position:absolute;background:#000;z-index:9999999;\"><pre>" . print_r($arg, true) . "</pre></div>"; } else { if (gettype($arg) === 'array') { $arg = "<a style=\"cursor:pointer\" onclick=\"var el=document.getElementById('{$rand}');if (el.style.display==='none'){el.style.display='block'}else{el.style.display='none'}\"><span style=\"color:#088\">Array:</span> " . count($arg) . " elements</a>" . "<div id=\"{$rand}\" style=\"display:none;border:1px solid #000;width:600px;height:150px;overflow:scroll;position:absolute;background:#000;z-index:9999999;\"><pre>" . print_r($arg, true) . "</pre></div>"; } else { $arg = "<span style=\"color:#088\">" . gettype($arg) . ":</span> " . $arg; } } } $implode = @implode("</span>] , [<span style=\"color:#0FF;\">", $bt['args']); $function = $bt['function'] . " ( [<span style=\"color:#0FF;\">" . $implode . "</span>] ) "; // if ( is_dir ( ROOT_DIR ) ) $bt['file'] = str_replace( ROOT_DIR , '' , $bt['file'] ); $backtraceOutput .= "\n<span style=\"font-family:courier new;font-size:10px;\"><span style=\"margin-top:0px;color:#888;padding-left:4px;\">" . $bt['file'] . ":" . $bt['line'] . " </span>->" . $function . "</span><br>"; } if ($db === false) { $db = ModelAbstract::$db; } if ($class) { // $class = "<span style=\"color:#FF0\">" . strtoupper ( $db->dsn['username']."@".$db->dsn['hostspec'] ) . "</span> - class " . $class . "()"; } else { // $class = "<span style=\"color:#FF0\">" . strtoupper ( $db->dsn['username']."@".$db->dsn['hostspec'] ) . "</span> - class ModelAbstract::()"; } if (!$executionStatus) { ModelAbstract::$hasError = true; } if ($executionStatus) { $executionStatus = 'OK'; } else { if ($errorMessage == '') { $executionStatus = '<span style="background:#A00;color:#FFF;font-weight:bold;"> ERROR </span>'; } else { $formatedMessage = ''; if (preg_match('/.*Error message:\\s*([^\\]]+)/', $errorMessage, $resultArr)) { $formatedMessage .= "<br/> " . $resultArr[1] . " "; } if (preg_match('/.*Native message:\\s*([^\\]]+)/', $errorMessage, $resultArr)) { $formatedMessage .= "<br/> Native Message: " . $resultArr[1]; } if ($formatedMessage !== '') { $errorMessage = '<span style="background:#A00;color:#FFF;font-weight:bold;"> ERROR </span>' . $formatedMessage; } $executionStatus = '<span style="background:#A00;color:#FFF;font-weight:bold;">' . $errorMessage . ' </span>'; } } if ($startTime !== false) { ModelAbstract::$totalExecutionTime += $endTime = microtime(TRUE) - $startTime; } else { $endTime = $startTime = '-'; } ModelAbstract::$queryHistory[] = array('query' => $query, 'time' => $endTime, 'status' => $executionStatus, 'class' => $class, 'backtrace' => $backtraceOutput); }