示例#1
0
文件: sqlsrv.php 项目: adjaika/J3Base
 /**
  * Method to optimize the index. We use this method to remove unused terms
  * and any other optimizations that might be necessary.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  * @throws  Exception on database error.
  */
 public function optimize()
 {
     // Get the database object.
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Delete all orphaned terms.
     $query->delete($db->quoteName('#__finder_terms'))->where($db->quoteName('links') . ' <= 0');
     $db->setQuery($query);
     $db->execute();
     // Remove the orphaned taxonomy nodes.
     FinderIndexerTaxonomy::removeOrphanNodes();
     return true;
 }
示例#2
0
 /**
  * Method to optimize the index. We use this method to remove unused terms
  * and any other optimizations that might be necessary.
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  * @throws  Exception on database error.
  */
 public function optimize()
 {
     // Get the database object.
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Delete all orphaned terms.
     $query->delete($db->quoteName('#__finder_terms'))->where($db->quoteName('links') . ' <= 0');
     $db->setQuery($query);
     $db->execute();
     // Optimize the links table.
     $db->setQuery('VACUUM ' . $db->quoteName('#__finder_links'));
     $db->execute();
     $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links'));
     $db->execute();
     for ($i = 0; $i <= 15; $i++) {
         // Optimize the terms mapping table.
         $db->setQuery('VACUUM ' . $db->quoteName('#__finder_links_terms' . dechex($i)));
         $db->execute();
         $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms' . dechex($i)));
         $db->execute();
     }
     // Optimize the terms mapping table.
     $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms'));
     $db->execute();
     // Remove the orphaned taxonomy nodes.
     FinderIndexerTaxonomy::removeOrphanNodes();
     // Optimize the taxonomy mapping table.
     $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_taxonomy_map'));
     $db->execute();
     return true;
 }
示例#3
0
 /**
  * Method to optimize the index. We use this method to remove unused terms
  * and any other optimizations that might be necessary.
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  * @throws  Exception on database error.
  */
 public static function optimize()
 {
     // Get the indexer state.
     $state = FinderIndexer::getState();
     // Get the database object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     // Delete all orphaned terms.
     $query->delete();
     $query->from($db->quoteName('#__finder_terms'));
     $query->where($db->quoteName('links') . ' <= 0');
     $db->setQuery($query);
     $db->query();
     // Check for a database error.
     if ($db->getErrorNum()) {
         // Throw database error exception.
         throw new Exception($db->getErrorMsg(), 500);
     }
     // Optimize the links table.
     //@TODO: PostgreSQL doesn't support OPTIMIZE TABLE
     // Temporary workaround for non-MySQL solutions
     if (strpos($db->name, 'mysql') === 0) {
         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links'));
         $db->query();
         // Check for a database error.
         if ($db->getErrorNum()) {
             // Throw database error exception.
             throw new Exception($db->getErrorMsg(), 500);
         }
     }
     //@TODO: PostgreSQL doesn't support OPTIMIZE TABLE
     // Temporary workaround for non-MySQL solutions
     if (strpos($db->name, 'mysql') === 0) {
         for ($i = 0; $i <= 15; $i++) {
             // Optimize the terms mapping table.
             $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links_terms' . dechex($i)));
             $db->query();
             // Check for a database error.
             if ($db->getErrorNum()) {
                 // Throw database error exception.
                 throw new Exception($db->getErrorMsg(), 500);
             }
         }
     }
     // Optimize the terms mapping table.
     //@TODO: PostgreSQL doesn't support OPTIMIZE TABLE
     // Temporary workaround for non-MySQL solutions
     if (strpos($db->name, 'mysql') === 0) {
         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links_terms'));
         $db->query();
         // Check for a database error.
         if ($db->getErrorNum()) {
             // Throw database error exception.
             throw new Exception($db->getErrorMsg(), 500);
         }
     }
     // Remove the orphaned taxonomy nodes.
     FinderIndexerTaxonomy::removeOrphanNodes();
     // Optimize the taxonomy mapping table.
     //@TODO: PostgreSQL doesn't support OPTIMIZE TABLE
     // Temporary workaround for non-MySQL solutions
     if (strpos($db->name, 'mysql') === 0) {
         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_taxonomy_map'));
         $db->query();
         // Check for a database error.
         if ($db->getErrorNum()) {
             // Throw database error exception.
             throw new Exception($db->getErrorMsg(), 500);
         }
     }
     return true;
 }