public function setup( $verbose ) {

		$db = wfGetDB( DB_MASTER );

		SNMDBHelper::reportProgress( "Setting up NotifyMe database ...\n", $verbose );

		extract( $db->tableNames( 'smw_nm_monitor', 'smw_nm_query', 'smw_nm_relations', 'smw_nm_rss' ) );

		// page_id, monitored page id
		SNMDBHelper::setupTable( $smw_nm_monitor, array(
			'notify_id' => 'INT(8) UNSIGNED NOT NULL',
			'page_id'   => 'INT(8) UNSIGNED NOT NULL' ), $db, $verbose );
		SNMDBHelper::setupIndex( $smw_nm_monitor, array( 'page_id' ), $db );
		SNMDBHelper::setupTable( $smw_nm_query, array(
			'notify_id' => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT',
			'user_id'   => 'INT(8) UNSIGNED NOT NULL',
			'delegate'  => 'BLOB',
			'name'      => 'VARCHAR(255) binary NOT NULL',
			'rep_all'   => 'TINYINT(1) NOT NULL default \'1\'',
			'show_all'  => 'TINYINT(1) NOT NULL default \'0\'',
			'query'     => 'BLOB NOT NULL',
			'nm_sql'    => 'BLOB',
			'nm_hierarchy' => 'BLOB',
			'enable'    => 'TINYINT(1) NOT NULL default \'0\'' ), $db, $verbose );
		SNMDBHelper::setupIndex( $smw_nm_query, array( 'user_id' ), $db );
		// page_id, related page / property id in notify query
		SNMDBHelper::setupTable( $smw_nm_relations, array(
			'notify_id'	=> 'INT(8) UNSIGNED NOT NULL',
			'smw_id'    => 'INT(8) UNSIGNED NOT NULL',
		// 0 category, 1 instance, 2 property
			'type'      => 'INT(8) UNSIGNED NOT NULL',
			'subquery'  => 'INT(8) UNSIGNED NOT NULL default \'0\'' ), $db, $verbose );
		SNMDBHelper::setupIndex( $smw_nm_relations, array( 'smw_id', 'notify_id' ), $db );
		SNMDBHelper::setupTable( $smw_nm_rss, array(
			'msg_id'    => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT',
			'mailed'    => 'TINYINT(1) NOT NULL default \'0\'',
			'user_id'   => 'INT(8) UNSIGNED',
			'notify_id' => 'INT(8) UNSIGNED',
			'title'     => 'VARCHAR(255) binary NOT NULL',
			'link'      => 'BLOB',
			'notify'    => 'BLOB NOT NULL',
			'timestamp' => 'VARCHAR(14) binary NOT NULL' ), $db, $verbose );
		SNMDBHelper::setupIndex( $smw_nm_rss, array( 'user_id' ), $db );

		SNMDBHelper::reportProgress( "... done!\n", $verbose );

	}
Esempio n. 2
0
 public static function getSQLOptionsAsString($requestoptions, $valuecol = NULL)
 {
     $options = SNMDBHelper::getSQLOptions($requestoptions, $valuecol);
     $limit = array_key_exists('LIMIT', $options) && is_numeric($options['LIMIT']) ? 'LIMIT ' . $options['LIMIT'] : '';
     $offset = array_key_exists('OFFSET', $options) && is_numeric($options['OFFSET']) ? 'OFFSET ' . $options['OFFSET'] : '';
     $orderby = array_key_exists('ORDER BY', $options) ? 'ORDER BY ' . $options['ORDER BY'] : '';
     return $orderby . ' ' . $limit . ' ' . $offset;
 }