Пример #1
0
 public static function restoreDatabase()
 {
     if (SwitchDatabase::$changedDB) {
         if (SwitchDatabase::isEcontentDatabase()) {
             SwitchDatabase::switchToVuFind();
         } else {
             SwitchDatabase::switchToEcontent();
         }
         SwitchDatabase::$changedDB = false;
     }
 }
Пример #2
0
 public function getRecordsListAvgRating($orderBy = "DESC", $limit = 30)
 {
     SwitchDatabase::switchToEcontent();
     $records = array();
     $sql = "SELECT ei.*, AVG(rating) as rate\n\t\t\t\tFROM econtent_rating er join econtent_item ei on er.recordId = ei.id\n\t\t\t\tWHERE 1 GROUP BY recordId ORDER BY rate " . $orderBy . ", recordId DESC LIMIT " . $limit;
     $result = mysql_query($sql);
     while ($row = mysql_fetch_assoc($result)) {
         unset($row['rate']);
         $econtentRecord = new EContentRecord();
         $econtentRecord->get($row['id']);
         $econtentRecord->setFrom($row, '');
         $records[] = $econtentRecord;
         unset($econtentRecord);
     }
     SwitchDatabase::restoreDatabase();
     return $records;
 }
Пример #3
0
require_once 'bootstrap.php';
require_once ROOT_DIR . '/sys/Utils/SwitchDatabase.php';
global $timer;
global $logger;
$library = new Library();
$library->find();
ob_start();
echo "<br>Starting to optimize tables<br/>\r\n";
$logger->log('Starting to optimize tables', PEAR_LOG_INFO);
ob_flush();
foreach ($configArray['Database'] as $key => $value) {
    if (preg_match('/table_(.*)/', $key, $matches)) {
        if ($value == 'vufind') {
            SwitchDatabase::switchToVuFind();
        } else {
            SwitchDatabase::switchToEcontent();
        }
        $tableName = $matches[1];
        //Some tables take too long to optimize, ignore them.
        if (in_array($tableName, array('analytics_session'))) {
            optimizeTable($tableName);
        }
    }
}
//Optimize tables that are not part of the browse definition
SwitchDatabase::switchToVuFind();
set_time_limit(300);
optimizeTable('title_browse');
optimizeTable('title_browse_metadata');
optimizeTable('title_browse_scoped_results_global');
optimizeTable('author_browse');