Corrected database prefix_ errors

This commit is contained in:
mchampan 2006-06-28 16:12:08 +00:00
parent d6e1bd8092
commit bef08835f7
5 changed files with 24 additions and 27 deletions

View File

@ -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;

View File

@ -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;
groupid int4
);
--ALTER TABLE search_documents OWNER TO postgres;
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);

View File

@ -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));

View File

@ -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

View File

@ -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 {