The MySQL default MyISAM storage engine, does not support thing handling, and the InnoDB storage Engine provides transactional security with commit, rollback, and crash resiliency. But compared to the MyISAM storage engine, InnoDB writes are less efficient and consume more disk space to preserve data and indexes
View the engine for the current database
Show variables like '%storage_engine% ';
View the engine used by the current table
Show table status from Ceshi where name= 'user';
Modifying the table engine method
ALTER TABLE user Engine=innodb;
Public Function index () {
$data [' name '] = ' piglet ';
$data [' pwd '] = ' 123456 ';
Start a transaction
Db::starttrans ();
try{
$res =db::table (' user ')->insert ($data);
Data with ID 2 does not exist
$res 2=db::table (' user ')->where (' id ', 2)->delete ();
if ($res && $res 2) {
Echo ' Operation succeeded ';
}else{
throw new \exception ("Delete ID 2 data not successful");
}
Commit a transaction
Db::commit ();
} catch (\exception $e) {
Rolling back a transaction
Db::rollback ();
Var_dump ($e->getmessage ());
}
TP 5.0 MySQL Things