At the moment "try catch" doesn't catch the error because the result is not complete. I.e. if the version is 3.0.0, it's gonna show = 3:
error_reporting(E_ALL & E_NOTICE);
try{
$query = "UPDATE \Models\Article SET views = views + 1 WHERE id = :id:";
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); //1
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); //2
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); //3
$art = Article::findFirst( $article->id );
var_dump( $art->views ); // 3
}catch( \PDOException $e ){
var_dump( $e->getMessage() );
}
But after the upgrade to 3.0.1 the code gives me = 1, i.e. try catch will work normally:
error_reporting(E_ALL & E_NOTICE);
try{
$query = "UPDATE \Models\Article SET views = views + 1 WHERE id = :id:";
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); // 1
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); // 1
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); // 1
$art = Article::findFirst( $article->id );
var_dump( $art->views ); // 1
}catch( \PDOException $e ){
var_dump( $e->getMessage() );
}
And another really weird thing is that if I run the mixed code PDO with Phalcon's ORM in 3.0.1 version, the code works fine:
error_reporting(E_ALL & E_NOTICE);
try{
$query = "UPDATE Article SET views = views + 1 WHERE id = ?";
\Phalcon\DI::getDefault()['db']->query($query, [$article->id]); // 1
\Phalcon\DI::getDefault()['db']->query($query, [$article->id]); // 2
$query = "UPDATE \Models\Article SET views = views + 1 WHERE id = :id:";
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); // 3
$article->getModelsManager()->createQuery( $query )->execute(['id' => $article->id]); // 4
$art = Article::findFirst( $article->id );
var_dump( $art->views ); // 4
}catch( \PDOException $e ){
var_dump( $e->getMessage() );
}