简体   繁体   English

PHP的PDO不要保存在表innodb

[英]php pdo don't save on table innodb

please some can help me ? 请一些可以帮助我吗?

i try to convert the hold php in pdo code but in general the codes does not work pdo if i use Innodb table esemple... this code save on table Myisam but not save if i trasform table in Innodb why ? 我尝试将pdo代码中的保留php转换,但是如果我使用Innodb表esemple,则通常该代码不起作用pdo ...此代码保存在表Myisam上,但是如果我在Innodb中转换表,为什么不保存?

try{
// lancio di una transazione con PDO
$pdo->beginTransaction();

//Preparazione query
$q = $pdo->prepare("INSERT INTO tipomiele (nometipomiele, notetipomiele) VALUES (:nometipomiele, :notetipomiele)");

//binding
$q->bindParam(':nometipomiele', $nometipomiele);
$q->bindParam(':notetipomiele', $notetipomiele);//ricorda di "collegare" la giusta variabile al bind

//esecuzione
$q->execute(); // eseguo la query


 }
 // se qualcosa non è andato a buon fine


 // blocco catch per la gestione delle eccezioni
catch(pdoException $e) {
///personalizzazione pagine di rientro
 echo 'Attenzione: '.$e->getMessage();

  // notifica in caso di errore
  $output = "Impossibile collegarsi al Data Base, Utente o Password errati" . "<br>" . "<br>" . "prego riprovare" . $e .
              "<br>" . "<br>" . "<a href='miele.php'>Clicca QUI per ritornare alla pagina principale</a>";
    include 'errore.html.php';
        // ritorno alla situazione precedente
        $pdo->rollBack();
        exit ();
}
// ritorno alla situazione precedente
$pdo->rollBack();
///////////////////////////////////////////////////////// 

You are rolling back your changes every time by calling $pdo->rollBack(); 您每次通过调用$pdo->rollBack();都会回滚更改$pdo->rollBack(); at the end of your script. 在脚本的末尾。 You should only call $pdo->rollBack(); 您应该只调用$pdo->rollBack(); in your catch block and remove the $pdo->rollBack(); 在您的catch块中并删除$pdo->rollBack(); and the end of your script. 以及脚本的结尾。

Your code is working with MyISAM tables because the MyISAM engine does not support transactions so that $pdo->rollBack(); 您的代码正在使用MyISAM表,因为MyISAM引擎不支持事务,因此$pdo->rollBack(); has no effect. 没有效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM