/** * Run the update * * @return boolean * @access public * @since 1/11/08 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); $query = new GenericSQLQuery(); $query->addSQLQuery("CREATE TABLE segue_plugin_version (\n version_id int(10) unsigned NOT NULL auto_increment,\n node_id varchar(170) collate utf8_bin NOT NULL,\n tstamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n `comment` varchar(255) collate utf8_bin NOT NULL,\n agent_id varchar(170) collate utf8_bin NOT NULL,\n version_xml longblob NOT NULL,\n PRIMARY KEY (version_id),\n KEY node_id (node_id)\n)\nCHARACTER SET utf8\nTYPE=InnoDB;"); $dbc->query($query); return true; }
/** * Run the update * * @return boolean * @access public */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $query = new GenericSQLQuery(); $query->addSQLQuery("CREATE TABLE IF NOT EXISTS segue_slot_migration_status (\n shortname varchar(50) collate utf8_bin NOT NULL,\n `status` enum('incomplete','archived','migrated','unneeded') collate utf8_bin NOT NULL default 'incomplete',\n status_date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n redirect_url text collate utf8_bin NOT NULL,\n user_id int(11) NOT NULL,\n PRIMARY KEY (shortname)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); try { $dbc->query($query); } catch (DatabaseException $e) { print "<p>" . $e->getMessage() . "</p>"; } return $this->isInPlace(); }
/** * Run the update * * @return boolean * @access public */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $query = new GenericSQLQuery(); $query->addSQLQuery("\nCREATE TABLE IF NOT EXISTS `site_export_queue` (\n `slot` varchar(255) collate utf8_bin NOT NULL,\n `priority` int(2) NOT NULL default '0',\n `status` varchar(10) collate utf8_bin default NULL,\n `info` text collate utf8_bin,\n `pid` int(10) default NULL,\n `tstamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n `running_time` float default NULL,\n PRIMARY KEY (`slot`),\n KEY `to_do` (`status`,`priority`,`slot`),\n KEY `pid` (`pid`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); try { $dbc->query($query); } catch (DatabaseException $e) { print "<p>" . $e->getMessage() . "</p>"; } return $this->isInPlace(); }
/** * Break up a SQL string with multiple queries (separated by ';') and run each * query * * @param string $queryString The string of queries. * @param integer $dbIndex The database index to run the queries on. * @return void * @access public * @since 7/2/04 * @static */ public static function multiQuery($queryString, $dbIndex) { // break up the query string. $queryStrings = explode(";", $queryString); $dbHandler = Services::getService("DatabaseManager"); // Run each query foreach ($queryStrings as $string) { $string = trim($string); if ($string) { $query = new GenericSQLQuery(); $query->addSQLQuery($string); $genericResult = $dbHandler->query($query, $dbIndex); } } }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function execute() { if (RequestContext::value('help') || RequestContext::value('h') || RequestContext::value('?')) { throw new HelpRequestedException("This is a command line script that will populate the OAI data tables from the \nrepositories in Concerto. It takes no arguments or parameters.\n"); } $harmoni = Harmoni::instance(); $config = $harmoni->getAttachedData('OAI_CONFIG'); if (!defined('OAI_UPDATE_OUTPUT_HTML')) { define("OAI_UPDATE_OUTPUT_HTML", TRUE); } while (ob_get_level()) { ob_end_flush(); } $harvesterConfig = $config->getProperty('OAI_HARVESTER_CONFIG'); if (!isset($_SESSION['oai_table_setup_complete'])) { $dbc = Services::getService("DatabaseManager"); $tables = $dbc->getTableList($config->getProperty('OAI_DBID')); foreach ($harvesterConfig as $configArray) { $table = 'oai_' . $configArray['name']; if (!in_array($table, $tables)) { $queryString = file_get_contents(dirname(__FILE__) . "/phpoai2/doc/oai_records_mysql.sql"); $queryString = str_replace('oai_records', $table, $queryString); $query = new GenericSQLQuery(); $query->addSQLQuery(SQLUtils::parseSQLString($queryString)); $dbc->query($query, $config->getProperty('OAI_DBID')); } } $_SESSION['oai_table_setup_complete'] = true; } $i = 1; foreach ($harvesterConfig as $configArray) { $tableMessage = "Updating table oai_" . $configArray['name'] . " (table " . $i . " of " . count($harvesterConfig) . ")"; if (OAI_UPDATE_OUTPUT_HTML) { print "\n<hr/><h2>" . $tableMessage . "</h2>"; } else { print "---------------------------------------------------\n| {$tableMessage}\n---------------------------------------------------\n"; } $this->updateTable($configArray['name'], $configArray['repository_ids'], $configArray['auth_group_ids']); $i++; print "\n\n"; } }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function execute() { if (!isset($_SESSION['oai_table_setup_complete'])) { $dbc = Services::getService("DatabaseManager"); $harmoni = Harmoni::instance(); $config = $harmoni->getAttachedData('OAI_CONFIG'); $tables = $dbc->getTableList($config->getProperty('OAI_DBID')); $harvesterConfig = $config->getProperty('OAI_HARVESTER_CONFIG'); foreach ($harvesterConfig as $configArray) { $table = 'oai_' . $configArray['name']; if (!in_array($table, $tables)) { $queryString = file_get_contents(dirname(__FILE__) . "/phpoai2/doc/oai_records_mysql.sql"); $queryString = str_replace('oai_records', $table, $queryString); $query = new GenericSQLQuery(); $query->addSQLQuery(SQLUtils::parseSQLString($queryString)); $dbc->query($query, $config->getProperty('OAI_DBID')); } } $_SESSION['oai_table_setup_complete'] = true; } require dirname(__FILE__) . "/phpoai2/oai2.php"; exit; }
/** * Run the update * * @return boolean * @access public * @since 3/20/08 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); try { $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `segue_slot` ADD `media_quota` INT;"); $dbc->query($query); } catch (QueryDatabaseException $e) { print "<p>" . $e->getMessage() . "</p>"; } try { $query = new GenericSQLQuery(); $query->addSQLQuery("CREATE TABLE segue1_id_map (\n segue1_slot_name varchar(50) NOT NULL,\n segue1_id varchar(50) NOT NULL,\n segue2_slot_name varchar(50) NOT NULL,\n segue2_id varchar(170) NOT NULL,\n PRIMARY KEY (segue1_id),\n UNIQUE KEY old_id_unique (segue1_slot_name,segue1_id),\n UNIQUE KEY new_id_unique (segue2_slot_name,segue2_id),\n KEY segue2_id (segue2_id)\n) ENGINE=InnoDB COMMENT='Mapping between segue1 and segue2 ids for auto-redirects.';"); $dbc->query($query); } catch (QueryDatabaseException $e) { print "<p>" . $e->getMessage() . "</p>"; } return $this->isInPlace(); }
/** * Does what is necessary to the temporary table for internal id association * * @access public * @since 10/6/05 */ function doIdMatrix() { $dbHandler = Services::getService("DBHandler"); // define dbIndexConcerto for children $createTableQuery = new GenericSQLQuery(); $createTableQuery->addSQLQuery("CREATE TEMPORARY TABLE\n\t\t\txml_id_matrix ( xml_id varchar(255)\n\t\t\tnot null , conc_id varchar(255) not null)"); $dbHandler->disconnect(IMPORTER_CONNECTION); $dbHandler->connect(IMPORTER_CONNECTION); $dbHandler->beginTransaction(IMPORTER_CONNECTION); // PostgreSQL doesn't seem to like the CREATE TEMPORARY TABLE IF NOT EXISTS syntax if (!in_array('xml_id_matrix', $dbHandler->getTableList(IMPORTER_CONNECTION))) { $dbHandler->query($createTableQuery, IMPORTER_CONNECTION); } }
/** * Run the update * * @return boolean * @access public * @since 7/9/07 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `dr_asset_info` ADD `creator` VARCHAR( 75 ) AFTER `create_timestamp`"); $dbc->query($query); return true; }
/** * Update a table/column * * @param string $table * @param string $column * @return boolean * @access private * @since 3/24/08 */ private function updateTable($table, $column) { $dbc = Services::getService('DatabaseManager'); $tables = $dbc->getTableList(); if (!in_array($table, $tables)) { return false; } $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `" . $table . "` CHANGE `" . $column . "` `" . $column . "` LONGBLOB NOT NULL"); $dbc->query($query); return true; }
/** * Run the update * * @return boolean * @access public * @since 7/9/07 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `segue_slot_owner` ADD UNIQUE `unique_owner` ( `shortname` , `owner_id` ) ;"); $dbc->query($query); return true; }
/** * Run the update * * @return boolean * @access public * @since 08/01/08 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `sets` DROP PRIMARY KEY;"); try { $dbc->query($query); } catch (DatabaseException $e) { } $query = new GenericSQLQuery(); $query->addSQLQuery(" ALTER TABLE `sets` ADD INDEX `set_item_index` ( `id` , `item_id` ) ;"); try { $dbc->query($query); } catch (DatabaseException $e) { } return $this->isInPlace(); }
/** * Returns a list of the tables that exist in the currently connected database. * @return array * @access public */ function getTableList() { $query = new GenericSQLQuery(); $query->addSQLQuery("SHOW TABLES"); $r = $this->query($query); $res = $r->returnAsSelectQueryResult(); $list = array(); while ($res->hasMoreRows()) { $list[] = $res->field(0); $res->advanceRow(); } $res->free(); return $list; }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $dbHandler = Services::getService("DBHandler"); $repositoryManager = Services::getService("Repository"); $setManager = Services::getService("Sets"); $idManager = Services::getService("Id"); print "lines 46 - 48 in expmdb.act.php need to be modified for database access"; // ===== ET (GOOD) MEDIADB DATABASE CONNECTION ===== // // $mdbIndex = $dbHandler->addDatabase( // new MySQLDatabase("host", "db", "uname", "password")); // $dbHandler->connect($mdbIndex); exit; // ===== CONCERTO DATABASE CONNECTION ===== // $dbHandler->disconnect(IMPORTER_CONNECTION); $dbHandler->connect(IMPORTER_CONNECTION); // ===== TMP TABLE FOR ID MATCHING ===== // $createTableQuery = new GenericSQLQuery(); $createTableQuery->addSQLQuery("Create table if not exists temp_id_matrix ( \n\t\t\tmedia_id int not null ,\n\t\t\tasset_id varchar(50) not null)"); $dbHandler->query($createTableQuery, $mdbIndex); // ===== COLLECTIONS QUERY ===== // $collectionsQuery = new SelectQuery(); $collectionsQuery->addTable("mediasets"); $collectionsQuery->addColumn("mediasets.id", "id"); $collectionsQuery->addColumn("mediasets.title", "name"); $collectionsQuery->addColumn("mediasets.fieldlist", "fieldlist"); $collectionsQuery->addColumn("mediasets.keywords", "description"); $collections = $dbHandler->query($collectionsQuery, $mdbIndex); $this->_folder = 'mdb1_conc2'; if (!is_dir("/tmp/" . $this->_folder)) { mkdir("/tmp/" . $this->_folder); } // ===== COLUMN TITLES FROM MEDIADB ===== // $this->_pSArray = explode(" ", "subject url creator category01 category02 date publisher contributor type format identifier source language relation coverage rights owner measurements material technique location id_number style_period culture"); $this->_dcArray = explode(" ", "title creator subject description publisher contributor date type format identifier source language relation coverage rights"); $this->_dc = count($this->_dcArray); $this->_vraArray = explode(" ", "title measurements material technique creator date location publisher contributor type format identifier id_number style_period culture subject relation description source rights"); $this->_vra = count($this->_vraArray); $this->openTopXML(); // ===== GO THROUGH EACH MEDIA SET(COLLECTION) ===== // while ($collections->hasMoreRows()) { $collection = $collections->next(); // ===== ASSETS QUERY ===== // $assetsQuery = new SelectQuery(); $assetsQuery->addTable("media"); $assetsQuery->addColumn("*"); $assetsQuery->addWhere("id_set = " . $collection['id']); $assets = $dbHandler->query($assetsQuery, $mdbIndex); // ===== MAKE SURE THE COLLECTION HAS ASSETS ===== // if ($assets->getNumberOfRows() > 0) { // ===== NEW XML FOR THE COLLECTION ITSELF ===== // $this->openCollectionXML($collection); $this->exportCollection($collection); // ===== WRITE THE MEDIADB RECORDSTRUCTURE INTO THIS XML ===== // $rSArray = $this->prepareRS($collection); $this->createRS($this->_currentXML, $rSArray, $collection['id']); $this->exportAssets($assets, $rSArray, $collection['id']); $this->closeCollectionXML(); } } $this->closeTopXML(); }
/** * Run the update * * @return boolean * @access public * @since 2/25/09 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); $query = new GenericSQLQuery(); $query->addSQLQuery(" ALTER TABLE `agent_external_children` CHANGE `fk_parent` `fk_parent` VARCHAR( 140 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,\nCHANGE `fk_child` `fk_child` VARCHAR( 140 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ;"); $dbc->query($query); return true; }
/** * Run the update * * @return boolean * @access public * @since 7/9/07 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `segue_slot` ADD `location_category` ENUM( 'main', 'community' ) NOT NULL ;"); $dbc->query($query); $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `segue_slot` ADD INDEX ( `location_category` ) ;"); $dbc->query($query); // Update the slots $slots = $slotMgr->getAllSlots(); while ($slots->hasNext()) { $slot = $slots->next(); printpre("Setting category " . $slot->getDefaultLocationCategory() . " for " . $slot->getShortname()); $slot->setLocationCategory($slot->getDefaultLocationCategory()); } return true; }
/** * Run the update * * @return boolean * @access public * @since 3/24/08 */ function runUpdate() { $dbc = Services::getService('DatabaseManager'); $slotMgr = SlotManager::instance(); try { $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `segue_slot` ADD `alias_target` VARCHAR(50);"); $dbc->query($query); } catch (QueryDatabaseException $e) { print "<p>" . $e->getMessage() . "</p>"; } try { $query = new GenericSQLQuery(); $query->addSQLQuery("ALTER TABLE `segue_slot` ADD FOREIGN KEY ( `alias_target` ) REFERENCES `afranco_segue2_prod`.`segue_slot` (`shortname`) ON DELETE SET NULL ON UPDATE CASCADE ;"); $dbc->query($query); } catch (QueryDatabaseException $e) { print "<p>" . $e->getMessage() . "</p>"; } return $this->isInPlace(); }