From bef08835f713d30a0c3eb9beff9346f98a59072c Mon Sep 17 00:00:00 2001 From: mchampan Date: Wed, 28 Jun 2006 16:12:08 +0000 Subject: [PATCH] Corrected database prefix_ errors --- search/db/mysql.sql | 7 +++---- search/db/postgres7.sql | 20 ++++++-------------- search/indexer.php | 14 ++++++++++---- search/indexersplash.php | 4 ++-- search/stats.php | 6 +++--- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/search/db/mysql.sql b/search/db/mysql.sql index 867b5751e0..8317ebbe40 100644 --- a/search/db/mysql.sql +++ b/search/db/mysql.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS `search_documents` ( +CREATE TABLE IF NOT EXISTS `prefix_search_documents` ( `id` int(11) NOT NULL auto_increment, `type` varchar(12) NOT NULL default 'none', `title` varchar(100) NOT NULL default '', @@ -10,6 +10,5 @@ CREATE TABLE IF NOT EXISTS `search_documents` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1; -DELETE FROM `search_documents` WHERE 1; -ALTER TABLE `search_documents` AUTO_INCREMENT =1; - +--DELETE FROM `prefix_search_documents`; +--ALTER TABLE `prefix_search_documents` AUTO_INCREMENT =1; \ No newline at end of file diff --git a/search/db/postgres7.sql b/search/db/postgres7.sql index 19e5fb3165..86b26849e5 100644 --- a/search/db/postgres7.sql +++ b/search/db/postgres7.sql @@ -1,21 +1,13 @@ ---probably a bit suspect, need to explicitly create ---id sequence (i.e. don't depend on postgres default seq naming)? ---not sure about table owner either - -CREATE TABLE search_documents -( - id serial, +CREATE TABLE prefix_search_documents ( + id SERIAL8 PRIMARY KEY, "type" varchar(12) NOT NULL DEFAULT 'none', title varchar(100) NOT NULL default '', url varchar(100) NOT NULL default '', updated timestamp NOT NULL DEFAULT NOW(), courseid int4, userid int4, - groupid int4, - CONSTRAINT id_pkey PRIMARY KEY (id) -) WITHOUT OIDS; - ---ALTER TABLE search_documents OWNER TO postgres; + groupid int4 +); -DELETE FROM search_documents; -SELECT setval('public.search_documents_id_seq', 1); +--DELETE FROM prefix_search_documents; +--SELECT setval('public.prefix_search_documents_id_seq', 1); \ No newline at end of file diff --git a/search/indexer.php b/search/indexer.php index b91b23ad21..0b9db792bc 100644 --- a/search/indexer.php +++ b/search/indexer.php @@ -54,9 +54,15 @@ $index = new Zend_Search_Lucene($index_path, true); //create the database tables - ob_start(); //turn output buffering on - to hide modify_database() output - modify_database($index_db_file, '', false); - ob_end_clean(); //chuck the buffer and resume normal operation + $tables = $db->MetaTables(); + + if (in_array($CFG->prefix.'search_documents', $tables)) { + delete_records('search_documents'); + } else { + ob_start(); //turn output buffering on - to hide modify_database() output + modify_database($index_db_file, '', false); + ob_end_clean(); //chuck the buffer and resume normal operation + } //else //empty database table goes here // delete * from search_documents; @@ -117,7 +123,7 @@ $doc->groupid = $document->groupid; //insert summary into db - $id = insert_record($CFG->prefix.'search_documents', $doc); + $id = insert_record('search_documents', $doc); //synchronise db with index $document->addField(Zend_Search_Lucene_Field::Keyword('dbid', $id)); diff --git a/search/indexersplash.php b/search/indexersplash.php index c10df92bd6..961c61c08a 100644 --- a/search/indexersplash.php +++ b/search/indexersplash.php @@ -22,8 +22,8 @@ //check if the table exists in the db $tables = $db->MetaTables(); - if (array_search('search_documents', $tables)) { - $db_count = count_records($CFG->prefix.'search_documents'); + if (in_array($CFG->prefix.'search_documents', $tables)) { + $db_count = count_records('search_documents'); } else { $db_count = 0; } //else diff --git a/search/stats.php b/search/stats.php index caf23e765c..dbe59c7228 100644 --- a/search/stats.php +++ b/search/stats.php @@ -13,15 +13,15 @@ //indexed documents stats $tables = $db->MetaTables(); - if (array_search('search_documents', $tables)) { + if (in_array($CFG->prefix.'search_documents', $tables)) { $types = search_get_document_types(); sort($types); //total documents - $type_counts['Total'] = count_records($CFG->prefix.'search_documents'); + $type_counts['Total'] = count_records('search_documents'); foreach($types as $type) { - $c = count_records($CFG->prefix.'search_documents', 'type', $type); + $c = count_records('search_documents', 'type', $type); $type_counts[$type] = (int)$c; } //foreach } else { -- 2.39.5