32 return str_replace(array(
' ',
"\t",
"\r",
"\n"),
'', $sStr);
44 if (!count(self::$_aSkipSqls)) {
46 if (is_readable($sFile)) {
47 $aSkip = explode(
'-- -- ENTRY END', file_get_contents($sFile));
48 foreach ($aSkip as $sQ) {
49 if (($sQ = self::_skipWhiteSpace($sQ))) {
50 self::$_aSkipSqls[md5($sQ)] =
true;
55 $checkTpl = md5(self::_skipWhiteSpace(self::_getSqlTemplate($sSql)));
56 $check = md5(self::_skipWhiteSpace($sSql));
58 return self::$_aSkipSqls[$check] || self::$_aSkipSqls[$checkTpl];
71 if (method_exists($oDb,
"logSQL")) {
72 $iLastDbgState = $oDb->logSQL(
false);
74 $rs = $oDb->select(
"select sql0, sql1, tracer from adodb_logsql order by created limit 5000");
75 if ($rs !=
false && $rs->recordCount() > 0) {
78 $sId = $rs->fields[0];
79 $sSql = $rs->fields[1];
81 if (!self::_isSkipped($sSql)) {
83 $aWarnings[
'MissingKeys'][$sId] =
true;
89 if ($aLastRecord && $this->
_checkMess($sSql, $aLastRecord[1])) {
91 $aWarnings[
'MESS'][$sId] =
true;
92 $aWarnings[
'MESS'][$aLastRecord[0]] =
true;
95 foreach ($aHistory as $aHistItem) {
98 $aWarnings[
'MESS_ALL'][$sId] =
true;
99 $aWarnings[
'MESS_ALL'][$aHistItem[0]] =
true;
103 $aHistory[] = $aLastRecord = $rs->fields;
113 if (method_exists($oDb,
"logSQL")) {
114 $oDb->logSQL($iLastDbgState);
131 foreach ($aInput as $fnc => $aWarnings) {
133 $rs = $oDb->select(
"select sql1, timer, tracer from adodb_logsql where sql0 in ($ids)");
134 if ($rs !=
false && $rs->recordCount() > 0) {
136 $aOutputEntry = array();
137 $aOutputEntry[
'check'] = $fnc;
138 $aOutputEntry[
'sql'] = $rs->fields[0];
139 $aOutputEntry[
'time'] = $rs->fields[1];
140 $aOutputEntry[
'trace'] = $rs->fields[2];
141 $aOutput[] = $aOutputEntry;
160 if (strpos(strtolower(trim($sSql)),
'select ') !== 0) {
165 if ($rs !=
false && $rs->recordCount() > 0) {
187 if ($aExplain[
'type'] ==
'system') {
191 if (strstr($aExplain[
'Extra'],
'Impossible WHERE') !==
false) {
195 if ($aExplain[
'key'] === null) {
199 if (strpos($aExplain[
'type'],
'range')) {
203 if (strpos($aExplain[
'type'],
'index')) {
207 if (strpos($aExplain[
'type'],
'ALL')) {
211 if (strpos($aExplain[
'Extra'],
'filesort')) {
212 if (strpos($aExplain[
'ref'],
'const') ===
false) {
217 if (strpos($aExplain[
'Extra'],
'temporary')) {
234 if (strpos(strtolower(trim($s1)),
'select ') !== 0) {
238 if (strpos(strtolower(trim($s2)),
'select ') !== 0) {
246 if (!strcmp($s1, $s2)) {
262 $sSql = preg_replace(
"/'.*?(?<!\\\\)'/",
"'#VALUE#'", $sSql);
263 $sSql = preg_replace(
'/".*?(?<!\\\\)"/',
'"#VALUE#"', $sSql);
264 $sSql = preg_replace(
'/[0-9]/',
'#NUMVALUE#', $sSql);
277 $sLogMsg =
"\n\n\n\n\n\n-- " . date(
"m-d H:i:s") .
" --\n\n";
278 foreach ($aWarnings as $w) {
279 $sLogMsg .=
"{$w['check']}: {$w['time']} - " . $oStr->htmlentities($w[
'sql']) .
"\n\n";
280 $sLogMsg .= $w[
'trace'] .
"\n\n\n\n";