33 return str_replace( array(
' ',
"\t",
"\r",
"\n"),
'', $sStr );
45 if ( !count(self::$_aSkipSqls ) ) {
47 if (is_readable($sFile)) {
48 $aSkip = explode(
'-- -- ENTRY END', file_get_contents( $sFile ));
49 foreach ( $aSkip as $sQ ) {
50 if ( ( $sQ = self::_skipWhiteSpace( $sQ ) ) ) {
51 self::$_aSkipSqls[md5($sQ)] =
true;
56 $checkTpl = md5(self::_skipWhiteSpace(self::_getSqlTemplate($sSql)));
57 $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) {
96 if ( $this->
_checkMess( $sSql, $aHistItem[1] ) ) {
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 );
130 foreach ($aInput as $fnc => $aWarnings) {
132 $rs = $oDb->select(
"select sql1, timer, tracer from adodb_logsql where sql0 in ($ids)");
133 if ($rs !=
false && $rs->recordCount() > 0) {
135 $aOutputEntry = array();
136 $aOutputEntry[
'check'] = $fnc;
137 $aOutputEntry[
'sql'] = $rs->fields[0];
138 $aOutputEntry[
'time'] = $rs->fields[1];
139 $aOutputEntry[
'trace'] = $rs->fields[2];
140 $aOutput[] = $aOutputEntry;
158 if ( strpos( strtolower( trim( $sSql ) ),
'select ' ) !== 0 ) {
163 if ( $rs !=
false && $rs->recordCount() > 0 ) {
184 if ( $aExplain[
'type'] ==
'system' ) {
188 if ( strstr($aExplain[
'Extra'],
'Impossible WHERE' ) !==
false ) {
192 if ( $aExplain[
'key'] === null ) {
196 if ( strpos( $aExplain[
'type'],
'range' ) ) {
200 if ( strpos($aExplain[
'type'],
'index' ) ) {
204 if ( strpos( $aExplain[
'type'],
'ALL' ) ) {
208 if ( strpos( $aExplain[
'Extra'],
'filesort' ) ) {
209 if ( strpos( $aExplain[
'ref'],
'const' ) ===
false ) {
214 if ( strpos( $aExplain[
'Extra'],
'temporary' ) ) {
231 if ( strpos( strtolower( trim( $s1 ) ),
'select ' ) !== 0 ) {
235 if ( strpos( strtolower( trim( $s2 ) ),
'select ' ) !== 0 ) {
243 if (!strcmp($s1, $s2)) {
259 $sSql = preg_replace(
"/'.*?(?<!\\\\)'/",
"'#VALUE#'", $sSql );
260 $sSql = preg_replace(
'/".*?(?<!\\\\)"/',
'"#VALUE#"', $sSql );
261 $sSql = preg_replace(
'/[0-9]/',
'#NUMVALUE#', $sSql );
276 $sLogMsg =
"\n\n\n\n\n\n-- ".date(
"m-d H:i:s").
" --\n\n";
277 foreach ( $aWarnings as $w ) {
278 $sLogMsg .=
"{$w['check']}: {$w['time']} - ".$oStr->htmlentities($w[
'sql']).
"\n\n";
279 $sLogMsg .= $w[
'trace'].
"\n\n\n\n";