From 42bec6048a30ca7e80853e4942dcc296c3c94759 Mon Sep 17 00:00:00 2001 From: wainstead Date: Wed, 21 Jun 2000 04:53:11 +0000 Subject: [PATCH] Debugged the InsertPage problem with adding new pages: 'flags' and 'pagename' were not defined and the database threw a fit about ,, showing up as a result. Wrote and debugged the search functions and they work now except they are case sensitive. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@80 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- wiki_pgsql.php3 | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/wiki_pgsql.php3 b/wiki_pgsql.php3 index c1a7f5145..6ef36caa0 100644 --- a/wiki_pgsql.php3 +++ b/wiki_pgsql.php3 @@ -1,4 +1,4 @@ - + dbi in InsertPage: '$dbi' '$dbi[table]' '$dbi[dbc]'

"; // prepare the content for storage + if (!isset($pagehash["pagename"])) + $pagehash["pagename"] = $pagename; + if (!isset($pagehash["flags"])) + $pagehash["flags"] = 0; $pagehash["author"] = addslashes($pagehash["author"]); $pagehash["content"] = implode("\n", $pagehash["content"]); $pagehash["content"] = addslashes($pagehash["content"]); @@ -136,8 +140,15 @@ // setup for title-search function InitTitleSearch($dbi, $search) { + + global $search_counter; + $search_counter = 0; + $search = addslashes($search); - $res = mysql_query("select page from $dbi[table] where page like '%$search%' order by page", $dbi["dbc"]); + $query = "select pagename from $dbi[table] where pagename " . + "like '%$search%' order by pagename"; +// echo "search query: $query
\n"; + $res = pg_exec($dbi["dbc"], $query); return $res; } @@ -145,10 +156,11 @@ // iterating through database function TitleSearchNextMatch($dbi, $res) { - if($o = mysql_fetch_object($res)) { - return $o->page; - } - else { + global $search_counter; + if($o = @pg_fetch_object($res, $search_counter)) { + $search_counter++; + return $o->pagename; + } else { return 0; } } @@ -156,17 +168,24 @@ // setup for full-text search function InitFullSearch($dbi, $search) { + global $search_counter; + $search_counter = 0; $search = addslashes($search); - $res = mysql_query("select page,hash from $dbi[table] where hash like '%$search%'", $dbi["dbc"]); + $query = "select pagename,content from $dbi[table] " . + "where content like '%$search%'"; + + $res = pg_exec($dbi["dbc"], $query); return $res; } // iterating through database function FullSearchNextMatch($dbi, $res) { - if($o = mysql_fetch_object($res)) { - $page['name'] = $o->page; - $page['hash'] = unserialize($o->hash); + global $search_counter; + if ($hash = @pg_fetch_array($res, $search_counter)) { + $search_counter++; + $page['name'] = $hash["pagename"]; + $page['hash']['content'] = explode("\n", $hash["content"]); return $page; } else { -- 2.45.0