From bbea19d4a83cc24052314d20c03384a9899c1750 Mon Sep 17 00:00:00 2001 From: wainstead Date: Fri, 16 Nov 2001 01:22:27 +0000 Subject: [PATCH] Fixed a bug with InitBackLinkSearch. Although I completely rewrote it, it turned out to be just a scope issue, and an ampersand would probably have fixed the original code. This implemetation is slightly more efficient at the cost of a small amount of memory. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/branches/release-1_2-branch@649 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/msql.php | 70 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/lib/msql.php b/lib/msql.php index 06a894475..733033815 100644 --- a/lib/msql.php +++ b/lib/msql.php @@ -1,4 +1,4 @@ -$query

\n"; + $res['res'] = msql_query($query, $dbi["dbc"]); + + $count = 0; + $arr = array(); + + // build an array of the results. + while ($hash = msql_fetch_array($res[res]) ) { + if ($arr[$count -1 ] == $hash[pagename]) + continue; + $arr[$count] = $hash[pagename]; + $count++; + } + + $res[count] = 0; + reset($arr); + $res[arr] = $arr; return $res; } - // iterating through database - function BackLinkSearchNextMatch($dbi, $res) { - while (true) { - if ( ! ($o = msql_fetch_object($res['res']))) { - return 0; - } - if ( $res['lastpage'] == $o->pagename ) - continue; - if ( ! preg_match($res['regexp'], $a->line) ) - continue; - $res['lastpage'] = $o->pagename; - return $o->pagename; - } - } +// iterating through database +function BackLinkSearchNextMatch($dbi, &$res) { + + if ($res[count] > count($res[arr])) + return 0; + + $retval = $res[arr][$res[count]]; + $res[count]++; + + return $retval; +} + +/* + if ( ($o = msql_fetch_object($res['res'])) == FALSE ) { + echo "returning zero

\n"; + echo "it's '$o'

\n"; + return 0; + } + if ( $res['lastpage'] == $o->pagename ) + continue; + if ( ! preg_match($res['regexp'], $a->line) ) + continue; + $res['lastpage'] = $o->pagename; + return $o->pagename; + } + */ + function IncreaseHitCount($dbi, $pagename) { -- 2.45.0