src/Pdx.php
function rm($dryrun = false, $harduninstall = false) {

		if ($this->locked) {
			return [null, 400];
		}
		else { // database is not locked

			$channels = $this->channels();
			$config = [ 'tables' => [] ];

			if ( ! $harduninstall) {

				list($history) = $this->history();

				// generate table list based on history
				foreach ($history as $i) {
					if ($i['hotfix'] === null) {
						$handlers = $channels[$i['channel']]['versions'][$i['version']];
					}
					else { // hotfix
						$handlers = $channels[$i['channel']]['versions'][$i['version']]['hotfixes'][$i['hotfix']];
					}

					$this->rm__load_tables($config, $handlers);
				}
			}
			else { // hard uninstall
				foreach ($channels as $channelname => $chaninfo) {
					foreach ($chaninfo['versions'] as $version => $handlers) {
						$this->rm__load_tables($config, $handlers);
						if (isset($handlers['hotfixes'])) {
							foreach ($handlers['hotfixes'] as $hotfix => $fixhandlers) {
								$this->rm__load_tables($config, $fixhandlers);
							}
						}
					}
				}
			}

			if ($this->has_history_table()) {
				$config['tables'][] = $this->table();
			}

			if ($dryrun) {
				return [$config['tables'], 0];
			}

			if ( ! empty($config['tables'])) {
				$dbh = $this->dbh();
				$dbh->prepare('SET foreign_key_checks = FALSE')
					->execute();

				foreach ($config['tables'] as $table) {
					$this->log(" Removing $table\n");
					$dbh->prepare("DROP TABLE IF EXISTS `$table`")
						->execute();
				}

				$dbh->prepare('SET foreign_key_checks = TRUE')
					->execute();
			}
			else { // empty tables
				$this->log("Nothing to remove.\n");
			}
		}

		return [null, 0];
	}
function rm($dryrun = false, $harduninstall = false) {

		if ($this->locked) {
			return [null, 400];
		}
		else { // database is not locked

			$channels = $this->channels();
			$config = [ 'tables' => [] ];

			if ( ! $harduninstall) {

				list($history) = $this->history();

				// generate table list based on history
				foreach ($history as $i) {
					if ($i['hotfix'] === null) {
						$handlers = $channels[$i['channel']]['versions'][$i['version']];
					}
					else { // hotfix
						$handlers = $channels[$i['channel']]['versions'][$i['version']]['hotfixes'][$i['hotfix']];
					}

					$this->rm__load_tables($config, $handlers);
				}
			}
			else { // hard uninstall
				foreach ($channels as $channelname => $chaninfo) {
					foreach ($chaninfo['versions'] as $version => $handlers) {
						$this->rm__load_tables($config, $handlers);
						if (isset($handlers['hotfixes'])) {
							foreach ($handlers['hotfixes'] as $hotfix => $fixhandlers) {
								$this->rm__load_tables($config, $fixhandlers);
							}
						}
					}
				}
			}

			if ($this->has_history_table()) {
				$config['tables'][] = $this->table();
			}

			if ($dryrun) {
				return [$config['tables'], 0];
			}

			if ( ! empty($config['tables'])) {
				$dbh = $this->dbh();
				$dbh->prepare('SET foreign_key_checks = FALSE')
					->execute();

				foreach ($config['tables'] as $table) {
					$this->log(" Removing $table\n");
					$dbh->prepare("DROP TABLE IF EXISTS `$table`")
						->execute();
				}

				$dbh->prepare('SET foreign_key_checks = TRUE')
					->execute();
			}
			else { // empty tables
				$this->log("Nothing to remove.\n");
			}
		}

		return [null, 0];
	}
function rm ( $ dryrun = false , $ harduninstall = false ) { if ( $ this -> locked ) { return [ null , 400 ] ; } else { // database is not locked $ channels = $ this -> channels ( ) ; $ config = [ 'tables' => [ ] ] ; if ( ! $ harduninstall ) { list ( $ history ) = $ this -> history ( ) ; // generate table list based on history foreach ( $ history as $ i ) { if ( $ i [ 'hotfix' ] === null ) { $ handlers = $ channels [ $ i [ 'channel' ] ] [ 'versions' ] [ $ i [ 'version' ] ] ; } else { // hotfix $ handlers = $ channels [ $ i [ 'channel' ] ] [ 'versions' ] [ $ i [ 'version' ] ] [ 'hotfixes' ] [ $ i [ 'hotfix' ] ] ; } $ this -> rm__load_tables ( $ config , $ handlers ) ; } } else { // hard uninstall foreach ( $ channels as $ channelname => $ chaninfo ) { foreach ( $ chaninfo [ 'versions' ] as $ version => $ handlers ) { $ this -> rm__load_tables ( $ config , $ handlers ) ; if ( isset ( $ handlers [ 'hotfixes' ] ) ) { foreach ( $ handlers [ 'hotfixes' ] as $ hotfix => $ fixhandlers ) { $ this -> rm__load_tables ( $ config , $ fixhandlers ) ; } } } } } if ( $ this -> has_history_table ( ) ) { $ config [ 'tables' ] [ ] = $ this -> table ( ) ; } if ( $ dryrun ) { return [ $ config [ 'tables' ] , 0 ] ; } if ( ! empty ( $ config [ 'tables' ] ) ) { $ dbh = $ this -> dbh ( ) ; $ dbh -> prepare ( 'SET foreign_key_checks = FALSE' ) -> execute ( ) ; foreach ( $ config [ 'tables' ] as $ table ) { $ this -> log ( " Removing $table\n" ) ; $ dbh -> prepare ( "DROP TABLE IF EXISTS `$table`" ) -> execute ( ) ; } $ dbh -> prepare ( 'SET foreign_key_checks = TRUE' ) -> execute ( ) ; } else { // empty tables $ this -> log ( "Nothing to remove.\n" ) ; } } return [ null , 0 ] ; }
Removes all tables.

@return boolean true if successful, false if not permitted
Removes all tables .