-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 '',
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
---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
$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;
$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));
//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
//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 {