]> git.mjollnir.org Git - moodle.git/commitdiff
Corrected database prefix_ errors
authormchampan <mchampan>
Wed, 28 Jun 2006 16:12:08 +0000 (16:12 +0000)
committermchampan <mchampan>
Wed, 28 Jun 2006 16:12:08 +0000 (16:12 +0000)
search/db/mysql.sql
search/db/postgres7.sql
search/indexer.php
search/indexersplash.php
search/stats.php

index 867b5751e0194b67e945fffa83989ed846b7d4d5..8317ebbe404b8428a5b47f42e3ab9492807db6d9 100644 (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;
\ No newline at end of file
index 19e5fb3165d477c415c7c0891e72024866e46482..86b26849e52af424881688777bff6e5e092ddef5 100644 (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;
-
---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 b91b23ad21a1d137dc74fd219ce956536649bff7..0b9db792bc7bd03196a5a960aae186399a206ebb 100644 (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));
index c10df92bd6b03ef7fc9fa2c5c58cbe815d1a3535..961c61c08a01c420aa401a900f70ef80b07d20ec 100644 (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    
index caf23e765cc93a6b28fab2394cab0e5f05e6bff7..dbe59c72285899c5907b85315470b5e9a3fb2f77 100644 (file)
     //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 {