src/Shell/DbMaintenanceShell.php
public function engine($engine = null) {
		$db = $this->_getConnection();
		$config = $db->config();
		$database = $config['database'];
		$prefix = ''; //$config['prefix'];
		$engines = ['InnoDB', 'MyISAM'];

		while (!$engine) {
			$engine = $this->in('Please select target engine', $engines);
		}
		if (!in_array($engine, $engines)) {
			$this->abort('Please provide a valid target format/engine.');
		}

		$script = <<<SQL
SELECT  CONCAT('ALTER TABLE `', table_name, '` ENGINE=$engine;') AS statement
FROM    information_schema.tables AS tb
WHERE   table_schema = '$database'
AND     table_name LIKE '$prefix%'
AND     `ENGINE` != '$engine'
AND     `TABLE_TYPE` = 'BASE TABLE';
SQL;
		/** @var \Cake\Database\Statement\StatementDecorator $res */
		$res = $db->query($script);
		if (!$res) {
			$this->abort('Nothing to do...');
		}

		$script = '';
		foreach ($res as $r) {
			$this->out($r['statement'], 1, Shell::VERBOSE);
			$script .= $r['statement'];
		}

		if (!$this->param('dry-run')) {
			$continue = $this->in(count($res) . ' tables will be altered.', ['Y', 'N'], 'N');
			if (strtoupper($continue) !== 'Y') {
				$this->abort('Aborted!');
			}
		}

		if (!$this->params['dry-run']) {
			$db->query($script);
		} else {
			$this->out($script);
		}
		$this->out('Done :)');
	}
public function engine($engine = null) {
		$db = $this->_getConnection();
		$config = $db->config();
		$database = $config['database'];
		$prefix = ''; //$config['prefix'];
		$engines = ['InnoDB', 'MyISAM'];

		while (!$engine) {
			$engine = $this->in('Please select target engine', $engines);
		}
		if (!in_array($engine, $engines)) {
			$this->abort('Please provide a valid target format/engine.');
		}

		$script = <<<SQL
SELECT  CONCAT('ALTER TABLE `', table_name, '` ENGINE=$engine;') AS statement
FROM    information_schema.tables AS tb
WHERE   table_schema = '$database'
AND     table_name LIKE '$prefix%'
AND     `ENGINE` != '$engine'
AND     `TABLE_TYPE` = 'BASE TABLE';
SQL;
		/** @var \Cake\Database\Statement\StatementDecorator $res */
		$res = $db->query($script);
		if (!$res) {
			$this->abort('Nothing to do...');
		}

		$script = '';
		foreach ($res as $r) {
			$this->out($r['statement'], 1, Shell::VERBOSE);
			$script .= $r['statement'];
		}

		if (!$this->param('dry-run')) {
			$continue = $this->in(count($res) . ' tables will be altered.', ['Y', 'N'], 'N');
			if (strtoupper($continue) !== 'Y') {
				$this->abort('Aborted!');
			}
		}

		if (!$this->params['dry-run']) {
			$db->query($script);
		} else {
			$this->out($script);
		}
		$this->out('Done :)');
	}
public function engine ( $ engine = null ) { $ db = $ this -> _getConnection ( ) ; $ config = $ db -> config ( ) ; $ database = $ config [ 'database' ] ; $ prefix = '' ; //$config['prefix']; $ engines = [ 'InnoDB' , 'MyISAM' ] ; while ( ! $ engine ) { $ engine = $ this -> in ( 'Please select target engine' , $ engines ) ; } if ( ! in_array ( $ engine , $ engines ) ) { $ this -> abort ( 'Please provide a valid target format/engine.' ) ; } $ script =  <<<SQL
SELECT  CONCAT('ALTER TABLE `', table_name, '` ENGINE=$engine;') AS statement
FROM    information_schema.tables AS tb
WHERE   table_schema = '$database'
AND     table_name LIKE '$prefix%'
AND     `ENGINE` != '$engine'
AND     `TABLE_TYPE` = 'BASE TABLE';
SQL ; /** @var \Cake\Database\Statement\StatementDecorator $res */ $ res = $ db -> query ( $ script ) ; if ( ! $ res ) { $ this -> abort ( 'Nothing to do...' ) ; } $ script = '' ; foreach ( $ res as $ r ) { $ this -> out ( $ r [ 'statement' ] , 1 , Shell :: VERBOSE ) ; $ script .= $ r [ 'statement' ] ; } if ( ! $ this -> param ( 'dry-run' ) ) { $ continue = $ this -> in ( count ( $ res ) . ' tables will be altered.' , [ 'Y' , 'N' ] , 'N' ) ; if ( strtoupper ( $ continue ) !== 'Y' ) { $ this -> abort ( 'Aborted!' ) ; } } if ( ! $ this -> params [ 'dry-run' ] ) { $ db -> query ( $ script ) ; } else { $ this -> out ( $ script ) ; } $ this -> out ( 'Done :)' ) ; }
Convert database table engine.

Args (optional)
- target engine (MyIsam, InnoDB)

@param string|null $engine Engine to convert to.
@return void
Convert database table engine .