Permalink
Browse files

Corrected database prefix_ errors

  • Loading branch information...
1 parent d6e1bd8 commit bef08835f713d30a0c3eb9beff9346f98a59072c mchampan committed Jun 28, 2006
Showing with 24 additions and 27 deletions.
  1. +3 −4 search/db/mysql.sql
  2. +6 −14 search/db/postgres7.sql
  3. +10 −4 search/indexer.php
  4. +2 −2 search/indexersplash.php
  5. +3 −3 search/stats.php
View
7 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;
View
20 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);
View
14 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));
View
4 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
View
6 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 {

0 comments on commit bef0883

Please sign in to comment.