includes/paths.php
changeset 259 112debff64bd
parent 256 f8356d9c3481
child 261 5f1cd51bf1be
--- a/includes/paths.php	Wed Dec 12 21:46:28 2007 -0500
+++ b/includes/paths.php	Sat Dec 15 18:10:14 2007 -0500
@@ -696,7 +696,12 @@
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
     // sha1('') returns "da39a3ee5e6b4b0d3255bfef95601890afd80709"
-    $texts = 'SELECT t.page_text, CONCAT(\'ns=\',t.namespace,\';pid=\',t.page_id) AS page_idstring, t.page_id, t.namespace FROM '.table_prefix.'page_text AS t
+    
+    $concat_column = ( ENANO_DBLAYER == 'MYSQL' ) ?
+      'CONCAT(\'ns=\',t.namespace,\';pid=\',t.page_id)' :
+      "'ns=' || t.namespace || ';pid=' || t.page_id";
+    
+    $texts = 'SELECT t.page_text, ' . $concat_column . ' AS page_idstring, t.page_id, t.namespace FROM '.table_prefix.'page_text AS t
                            LEFT JOIN '.table_prefix.'pages AS p
                              ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
                            WHERE p.namespace=t.namespace
@@ -810,13 +815,26 @@
     $search->buildIndex(Array("ns={$namespace};pid={$page_id}"=>$row['page_text'] . ' ' . $this->pages[$idstring]['name']));
     $new_index = $search->index;
     
-    $keys = array_keys($search->index);
-    foreach($keys as $i => $k)
+    if ( ENANO_DBLAYER == 'MYSQL' )
     {
-      $c =& $keys[$i];
-      $c = hexencode($c, '', '');
+      $keys = array_keys($search->index);
+      foreach($keys as $i => $k)
+      {
+        $c =& $keys[$i];
+        $c = hexencode($c, '', '');
+      }
+      $keys = "word=0x" . implode ( " OR word=0x", $keys ) . "";
     }
-    $keys = "word=0x" . implode ( " OR word=0x", $keys ) . "";
+    else
+    {
+      $keys = array_keys($search->index);
+      foreach($keys as $i => $k)
+      {
+        $c =& $keys[$i];
+        $c = $db->escape($c);
+      }
+      $keys = "word='" . implode ( "' OR word='", $keys ) . "'";
+    }
     
     $query = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index WHERE '.$keys.';');