34 return str_replace(array(
' ',
"\t",
"\r",
"\n"),
'', $sStr);
46 if (!count(self::$_aSkipSqls)) {
48 if (is_readable($sFile)) {
49 $aSkip = explode(
'-- -- ENTRY END', file_get_contents($sFile));
50 foreach ($aSkip as $sQ) {
51 if (($sQ = self::_skipWhiteSpace($sQ))) {
52 self::$_aSkipSqls[md5($sQ)] =
true;
57 $checkTpl = md5(self::_skipWhiteSpace(self::_getSqlTemplate($sSql)));
58 $check = md5(self::_skipWhiteSpace($sSql));
60 return self::$_aSkipSqls[$check] || self::$_aSkipSqls[$checkTpl];
73 if (method_exists($oDb,
"logSQL")) {
74 $iLastDbgState = $oDb->logSQL(
false);
76 $rs = $oDb->select(
"select sql0, sql1, tracer from adodb_logsql order by created limit 5000");
77 if ($rs !=
false && $rs->recordCount() > 0) {
80 $sId = $rs->fields[0];
81 $sSql = $rs->fields[1];
83 if (!self::_isSkipped($sSql)) {
85 $aWarnings[
'MissingKeys'][$sId] =
true;
91 if ($aLastRecord && $this->
_checkMess($sSql, $aLastRecord[1])) {
93 $aWarnings[
'MESS'][$sId] =
true;
94 $aWarnings[
'MESS'][$aLastRecord[0]] =
true;
97 foreach ($aHistory as $aHistItem) {
100 $aWarnings[
'MESS_ALL'][$sId] =
true;
101 $aWarnings[
'MESS_ALL'][$aHistItem[0]] =
true;
105 $aHistory[] = $aLastRecord = $rs->fields;
115 if (method_exists($oDb,
"logSQL")) {
116 $oDb->logSQL($iLastDbgState);
133 foreach ($aInput as $fnc => $aWarnings) {
135 $rs = $oDb->select(
"select sql1, timer, tracer from adodb_logsql where sql0 in ($ids)");
136 if ($rs !=
false && $rs->recordCount() > 0) {
138 $aOutputEntry = array();
139 $aOutputEntry[
'check'] = $fnc;
140 $aOutputEntry[
'sql'] = $rs->fields[0];
141 $aOutputEntry[
'time'] = $rs->fields[1];
142 $aOutputEntry[
'trace'] = $rs->fields[2];
143 $aOutput[] = $aOutputEntry;
162 if (strpos(strtolower(trim($sSql)),
'select ') !== 0) {
167 if ($rs !=
false && $rs->recordCount() > 0) {
189 if ($aExplain[
'type'] ==
'system') {
193 if (strstr($aExplain[
'Extra'],
'Impossible WHERE') !==
false) {
197 if ($aExplain[
'key'] === null) {
201 if (strpos($aExplain[
'type'],
'range')) {
205 if (strpos($aExplain[
'type'],
'index')) {
209 if (strpos($aExplain[
'type'],
'ALL')) {
213 if (strpos($aExplain[
'Extra'],
'filesort')) {
214 if (strpos($aExplain[
'ref'],
'const') ===
false) {
219 if (strpos($aExplain[
'Extra'],
'temporary')) {
236 if (strpos(strtolower(trim($s1)),
'select ') !== 0) {
240 if (strpos(strtolower(trim($s2)),
'select ') !== 0) {
248 if (!strcmp($s1, $s2)) {
264 $sSql = preg_replace(
"/'.*?(?<!\\\\)'/",
"'#VALUE#'", $sSql);
265 $sSql = preg_replace(
'/".*?(?<!\\\\)"/',
'"#VALUE#"', $sSql);
266 $sSql = preg_replace(
'/[0-9]/',
'#NUMVALUE#', $sSql);
279 $sLogMsg =
"\n\n\n\n\n\n-- " . date(
"m-d H:i:s") .
" --\n\n";
280 foreach ($aWarnings as $w) {
281 $sLogMsg .=
"{$w['check']}: {$w['time']} - " . $oStr->htmlentities($w[
'sql']) .
"\n\n";
282 $sLogMsg .= $w[
'trace'] .
"\n\n\n\n";